我正在尝试提取此页面的html源代码http://www.fxstreet.com/rates-charts/currency-rates/
我想要我从chrome中将页面另存为.html文件时看到的内容。
我试着在java中做到这一点,先使用bufferedreader,然后再使用jsoup。我也尝试过用python来做这件事,但是我一直收到下面的消息:
“此网站要求启用JavaScript和Cookie。请更改浏览器设置或升级浏览器。”
最终目标是提取主表中的值。
发布于 2012-06-02 05:51:22
尝试使用HtmlUnit并设置setJavascriptEnabled(true)
另请参阅:this和this
JSoup不是执行Javascript的无头浏览器,所以您必须选择其他库来获取页面,然后才能使用JSoup解析它。
发布于 2012-12-09 23:56:57
只需提取主表就可以使用Jsoup轻松完成
下面是一个方法,它将获取页面上主表中的所有内容
public void parse(){
try{
Document doc = Jsoup.connect("http://www.fxstreet.com/rates-charts/currency-rates/").get();
Element content = doc.getElementById("ddlPairsChoose");
Elements table = doc.getElementsByClass("applet-content");
System.out.print(table);
}
catch(Exception e){
System.out.print("error --> " + e);
}
}它打印出页面上的表格
https://stackoverflow.com/questions/10857780
复制相似问题