필터 지우기
필터 지우기

Getting data from the internet

조회 수: 4 (최근 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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by