java - Using JSoup to scrape Google Weather Results -


i'm trying weather condition google web page, , there tag on html elements wob_tm, tried value, exception

 try {       document  document = jsoup.connect("https://www.google.jo/webhp?hl=en#hl=en-jo&q=amman+weather").get();       element temp = document.getelementbyid("wob_tm");       system.out.println(temp.text()); // exception in thread "main" java.lang.nullpointerexception     } catch (ioexception ex) {         logger.getlogger(main.class.getname()).log(level.severe, null, ex);     } 

enter image description here

there error in query , should define user agent

document doc = jsoup     .connect("https://www.google.com/search?q=mario");     .useragent("mozilla/5.0")     .timeout(5000).get(); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -