为什么使用urlopen抓取数据时缺少内容/值?

时间:2020-07-08 16:05:03

标签: javascript python web-crawler urlopen crawler4j

我只是使用以下Python代码来抓取数据

html = urlopen("https://www.hkex.com.hk/?sc_lang=en").read().decode('utf-8') 
print(html)

但是我错过了内容,只有得到

<div class="type value"></div>

我的目标是获得

<div class="type value">HK$24,225M</div>  or HK$24,225M

enter image description here

1 个答案:

答案 0 :(得分:1)

此网站上的数据使用JavaScript更新。尝试在浏览器中按Ctrl + U。

在此示例中,数据是从https://www.hkex.com.hk/eng/csm/script/data_NBSZ_Turnover_eng.jsdata_SBSZ_Turnover_eng.js获取的。 (我不知道你需要什么)

将来,请查看开发人员工具中的“网络”标签,在那里可能会找到所需的内容。