开发者

Using YQL and XPath to get data from HTML

开发者 https://www.devze.com 2023-03-16 12:07 出处:网络
I\'ve been playing around with YQL to try and understand it better as it seems like a pretty neat service but I have to admit Im quite the newbie when it comes it.I\'ve worked through some of the tuto

I've been playing around with YQL to try and understand it better as it seems like a pretty neat service but I have to admit Im quite the newbie when it comes it. I've worked through some of the tutorials and examples and do understand it to a degree. W开发者_开发问答hat I decided to do next was try and pull statistics from a website to display the league stats on a potential team site to see if it would work.

My YQL query was

select * from html
where url="http://www.nwjhl.com/leagues/standingsTotals.cfm?leagueID=15654&clientID=4594"

which returned some results, but obviously I dont need the entire contents, Im just trying to pull the standings. I have managed to display the results on a local page but when I try to narrow down the results to just the team standings I get no results returned in the tree. Im assuming it has to do with my xpath

select * from html
where url="http://www.nwjhl.com/leagues/standingsTotals.cfm?leagueID=15654&clientID=4594"
and xpath="/html/body/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr[2]"

Being new I dont know if this is possible, just wondering if someone can steer me on the right track or knows of a good tutorial for this case.


This should be what you want:

SELECT * FROM html 
WHERE url="http://www.nwjhl.com/leagues/standingsTotals.cfm?leagueID=15654&clientID=4594" 
AND xpath="//tr[@class='boxscores_tables1'] | //tr[@class='boxscores_tables2']"
0

精彩评论

暂无评论...
验证码 换一张
取 消