Getting data from the internet

5 ビュー (過去 30 日間)
Deha Ay
Deha Ay 2020 年 8 月 9 日
コメント済み: Deha Ay 2020 年 8 月 13 日
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

採用された回答

Sourabh Kondapaka
Sourabh Kondapaka 2020 年 8 月 13 日
編集済み: Sourabh Kondapaka 2020 年 8 月 13 日
Hi,
You can use “webread()” to scrape and then usehtmlTree() 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.
For more information on CSS Selectors please check here under “CSS Selectors” section.
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;
  1 件のコメント
Deha Ay
Deha Ay 2020 年 8 月 13 日
thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by