我正在尝试使用Java上的Jsoup获取amazon价格
我想得到亚马逊产品的价格,然后将其放入电子表格中,并将价格放在时间旁边。我正在尝试为此使用Jsoup(我对此非常陌生) 这就是我现在拥有的。 我甚至不能得到价格,所以这是我最需要的帮助我正在尝试使用Java上的Jsoup获取amazon价格,java,jsoup,amazon,fetch,Java,Jsoup,Amazon,Fetch,我想得到亚马逊产品的价格,然后将其放入电子表格中,并将价格放在时间旁边。我正在尝试为此使用Jsoup(我对此非常陌生) 这就是我现在拥有的。 我甚至不能得到价格,所以这是我最需要的帮助 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the 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 the 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);
}
}
您在这里没有什么问题:
文档。选择
返回一个元素
,而不是字符串
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 is " + question.html());
您在这里没有什么问题:
文档。选择
返回一个元素
,而不是字符串
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 is " + question.html());