简体   繁体   English

jsoup从网站获取数据

[英]jsoup get data from website

I am using Java jsoup to get the "Last" price from http://www.aastocks.com/en/ltp/rtquote.aspx?symbol=00055&process=y 我正在使用Java jsoup从http://www.aastocks.com/zh_CN/ltp/rtquote.aspx?symbol=00055&process=y获得“最后”价格

My code: 我的代码:

String price = null;
Document document = Jsoup.connect("http://www.aastocks.com/tc/ltp/rtquote.aspx?symbol=00055").ignoreHttpErrors(true).timeout(5*1000).get();  // s
Elements answerers = document.select(".C.font28.bold ");
price = answerer.text();
        }

 System.out.println(price);

But it returns: 但它返回:

run:

BUILD SUCCESSFUL (total time: 0 seconds)

Please help 请帮忙

To get eg the CSS Selector with Firefox: 要获得例如Firefox的CSS选择器:

  • right-click on the Element of which you want to get the Selector. 右键单击要获取选择器的元素。
  • Choose "inspect" or "inspect with Firebug". 选择“检查”或“检查Firebug”。
  • Then right-click the selected source and choose "Copy CSS Path". 然后右键单击选定的源,然后选择“复制CSS路径”。

You would get this CSS Path: 您将获得以下CSS路径:

html body div#AAMainMaster div.floatL div.frame_w.floatL div div.c_w div.div-container div.RContentBox.floatL form#aspnetForm div.div-container div.floatL div.div-container.bmp-s1 div#rtQuoteRightContent.floatL div.div-container table.tb-s4 tbody tr td.DR.bold html正文div#AAMainMaster div.floatL div.frame_w.floatL div div.c_w div.div容器div.RContentBox.floatL form#aspnetForm div.div容器div.floatL div.div-container.bmp-s1 div#rtQuoteRight .floatL div.div容器表.tb-s4 tbody tr td.DR.bold

Hope this helps 希望这可以帮助

regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM