Fetching "Inspect Elements" from HTML

6 次查看(过去 30 天)
Anton
Anton 2015-9-7
评论: Anton 2015-9-8
Hello
So i dont know if this can be done or not, but i have not been able to find any posts about it. What i want to do is fetch information that changes in diffrent elements on a HTML page. To simply download the page source using URLread gives me nothing since the values are not stored there. It might just be my lack of knowledge about HTML that makes me ask this question, but so be it.
Thanks in advance
  2 个评论
Cedric
Cedric 2015-9-7
编辑:Cedric 2015-9-7
Could you provide the URL of a few of these pages, and explain what you are trying to extract?
Anton
Anton 2015-9-7
What i am trying to extract is odds from a betting site. I was asked by a friend to plot over time how the odds changes before the game starts to find a "sweet-spot" to place the bet.
Here is the URL i've been using: https://svenskaspel.se/?pageid=/sport/oddsetlangen
Its a Swedish betting site, if you wonder why its filled with jibberish.

请先登录,再进行评论。

回答(1 个)

Guillaume
Guillaume 2015-9-7
编辑:Guillaume 2015-9-7
If the data you're interested in gets displayed through javascript then there's not much you can do short of implementing your own web browser (at least the javascript interpreting bit) in matlab or interacting with an existing browser. See this related discussion.
Possibly, the website you're accessing may have an API to fetch the data you want, most likely using xml. In that case, you could use webread.
  4 个评论
Cedric
Cedric 2015-9-8
编辑:Cedric 2015-9-8
Image recognition will not work too well either, because you have to open pages manually, take a screen shot, etc, so this cannot be done on a regular and fast basis.
If I were you, I would try to see if I could access the content after the JS (or whatever else) is execute, from e.g.
web( 'https://svenskaspel.se/?pageid=/sport/oddsetlangen' )
or from Firefox. If you open the page in Firefox, right click on one of the numbers and select "Inspect element (Q)", you will see that the inspector tool displays the value. There may be a way to get this information from some plugin rather than the raw HTML source which contains the call.
Anton
Anton 2015-9-8
I've sorted out to open the page, screen shot it and crop out the diffrent odds, so i guess is should be doable with image recognition.
Apparently the built-in browser in matlab cant inspect specific elements which is a shame really - or at least i cant figure out how to do it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by