Getting data from the internet
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Deha Ay
am 9 Aug. 2020
Kommentiert: Deha Ay
am 13 Aug. 2020
Hello everyone,
I am writing a code with the help of previous knowledge from this website, that is suppose to take the dolar rates from this website;
the exchange rate that I am trying to get is the one under "Satış" I have also attached a picture below.
This is the code I have, the error that is giving me is that :
Target string Sat?? does not appear.. Because the last two characters are not english, matlab replaces it with a question mark. Instead of doing name = 'Satış'; when I changed it to "Akbank" or any other name that is mentioned down below the page, it gives me a number that is under 'Alış' which is the right to the left of what I want. How can I fix the problem?
clc
url = 'https://kur.doviz.com/serbest-piyasa/amerikan-dolari';
name = 'Satış';
raw_price = urlfilter(url,name);
actual_price = raw_price/10000
0 Kommentare
Akzeptierte Antwort
Sourabh Kondapaka
am 13 Aug. 2020
Bearbeitet: Sourabh Kondapaka
am 13 Aug. 2020
Hi,
You can use “webread()” to scrape and then use “htmlTree()” to convert the string to a html tree. Then you can use “findElement()” to find elements of a specific type.
To find more details about the html element ‘Satış’ is in. Right Click on ‘Satış’ and click on “Inspect Element”.
You can see that ‘Satış’ is in a div which has a class ‘data’. You can use this information in the “findElement()” function.
url = 'https://kur.doviz.com/serbest-piyasa/amerikan-dolari';
data = webread(url);
tree = htmlTree(data);
subTree = findElement(tree, 'div .data');
satis_Div = subTree.Children(4);
satis_Value = satis_Div.Children(4).extractHTMLText;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!