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); }
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
Post a Comment