Getting data from the internet
14 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Sourabh Kondapaka
on 13 Aug 2020
Edited: Sourabh Kondapaka
on 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;
More Answers (0)
See Also
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!