Convert xPath to JSoup query -
does know of xpath jsoup convertor? following xpath chrome:
//*[@id="docs"]/div[1]/h4/a
and change jsoup query. path contains href i'm trying reference.
this easy convert manually.
something (not tested)
document.select("#docs > div:eq(1) > h4 > a").attr("href");
documentation:
http://jsoup.org/cookbook/extracting-data/selector-syntax
related question comment
trying href first result here: cbssports.com/info/search#q=fantasy%20tom%20brady
code
elements select = jsoup.connect("http://solr.cbssports.com/solr/select/?q=fantasy%20tom%20brady") .get() .select("response > result > doc > str[name=url]"); (element element : select) { system.out.println(element.html()); }
result
http://fantasynews.cbssports.com/fantasyfootball/players/playerpage/187741/tom-brady http://www.cbssports.com/nfl/players/playerpage/187741/tom-brady http://fantasynews.cbssports.com/fantasycollegefootball/players/playerpage/1825265/brady-lisoski http://fantasynews.cbssports.com/fantasycollegefootball/players/playerpage/1766777/blake-brady http://fantasynews.cbssports.com/fantasycollegefootball/players/playerpage/1851211/brady-foltz http://fantasynews.cbssports.com/fantasycollegefootball/players/playerpage/1860955/brady-earnhardt http://fantasynews.cbssports.com/fantasycollegefootball/players/playerpage/1673397/brady-amack
screenshot developer console - grabbing urls
Comments
Post a Comment