java - Jsoup href request and to output on file -


i made sample request 1 url query through java application. request connection , query right. but, i'm missing how able href elements query , write on 1 output file? has guidelines?

thanks in advance

document enginesearch=jsoup.connect("http://ask.com/web?q="+urlencoder.encode(query))                                         .useragent("mozilla/5.0 (x11; u; linux x86_64; en-gb; rv:1.8.1.6) gecko/20070723 iceweasel/2.0.0.6 (debian-2.0.0.6-0etch1)")                                         .get();             string title = enginesearch.title();             elements links = enginesearch.select("a[href]").first().getallelements();              string queryencoding=enginesearch.outputsettings().charset().name();          file = new file(folder.getpath()+"\\"+date+" "+tag+".html");          outputstreamwriter writer = new outputstreamwriter(new fileoutputstream(file),queryencoding);         writer.write(enginesearch.html());         writer.close(); 

here example of want, dont have dev environment handy along lines should work

http://jsoup.org/cookbook/extracting-data/attributes-text-html

document doc = jsoup.parse(html); elements links = doc.select("a");  (element e : links) {  string text = doc.body().text(); // "an example link"  string linkhref = link.attr("href"); // "http://example.com/", can save file } 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -