Getting data from the internet
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sourabh Kondapaka
2020-8-13
编辑:Sourabh Kondapaka
2020-8-13
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;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!