web - Java get single element from webpage -


hi after searching still not found answer single element of webpage string variable. know how in c know in java

eg:

document.nav(the webpage) string value = document.getelementbyid(theid) 

thanks

so eg:

some webpage has

<body> <p id=element1>the value want</p> </body> 

and need value webpage string variable

you can use jsoup that:

string url = "http://www.example.com"; // or whatever goes here document document = jsoup.connect(url).followredirects(false).timeout(60000/*wait 60 sec response*/).get(); string value = document.body().select("#element1" /*css selector*/).get(0).text(); 

if need input format please refer the cookbook

it's not necessary specify timeout ect. connection. use

document document = jsoup.connect(url).get(); 

i included timeout if webpage takes long load. may want follow redirects.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -