I am trying to fetch amazon prices using Jsoup on Java -
i want prices of amazon product , put them spreadsheet price next time. trying use jsoup (and new this) have. cant price need with
/* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ package amazon; /** * * @author kennethkreindler */ import java.io.ioexception; import org.jsoup.jsoup; import org.jsoup.nodes.document; import org.jsoup.nodes.element; import org.jsoup.select.elements; public class amazonmain { /** * @param args command line arguments * @throws java.lang.exception */ public static void main(string[] args) throws exception { string url = "http://www.amazon.de/dji-cp-pt-000498-mavic-drohne-grau/dp/b01m0avo1p/"; document document = jsoup.connect(url).useragent("mozilla/17.0").get(); string question = document.select("span.priceblock_ourprice"); system.out.println("price is" + question); } }
you have few issues here:
- your user agent outdated, totally different response expect. use newer one.
document.selectreturnselement, notstring.your seletor not right. use following code:
string url = "http://www.amazon.de/dji-cp-pt-000498-mavic-drohne-grau/dp/b01m0avo1p/"; document document = jsoup.connect(url).useragent("mozilla/49.0").get(); elements question = document.select("#priceblock_ourprice"); system.out.println("price " + question.html());
Comments
Post a Comment