-1
我有以下代碼從雅虎finance.hk 的滴答價格,但它總是返回超時錯誤 請幫Jsoup總是返回超時錯誤
public GetStockPriceFromWebOneByOne(String url){
this.url = url;
}
private void setDataFromAAStock() throws IOException, InterruptedException{
Document document = Jsoup.connect(url).ignoreHttpErrors(true).timeout(timeOut*1000).get(); // s
//TimeUnit.SECONDS.sleep(2);
Elements answerers = document.select("div.yfi_rt_quote_summary div.yfi_rt_quote_summary_rt_top.sigfig_promo_0 span.time_rtq_ticker");
// Elements answerers = document.select(".content .inline_block.vat.float_l .boxForex .font26 .neg .arr_ud.arrow_d6");
for (Element answerer : answerers) {
//System.out.print(answerer.text()+"\n");
price = answerer.text();
// splitString(answerer.text());
}
}
public String getDataFromAAStock() throws IOException, InterruptedException{
setDataFromAAStock();
return price;
}
我試圖使用userAgent和不使用userAgent方法,都不是wroks –
@WaiHung看到我的修改回答 – luksch
仍然無法正常工作 –