【发布时间】:2021-07-27 06:53:44
【问题描述】:
我需要从这个 URL hkex.com.hk 获取包含信息的 JSON,我可以使用 firefox>developer tools>network 并寻找我想要的 JSON,我需要使用 python 做同样的事情,所以远我有这个
url='https://www.hkex.com.hk/Market-Data/Securities-Prices/Equities?sc_lang=en'
r = requests.get(url)
print(r.text)
但我只收到一个 HTML,所以即使在使用 .json() 之后,我也会收到错误“期望值”,因为它是空的,我该如何实现呢?
【问题讨论】:
-
您要提取页面的哪一部分?
-
表中的信息 "hkex.com.hk/Market-Data/Securities-Prices/Equities?sc_lang=en" 我可以在网络中找到它>其他有 3 个 .JSON 我需要最后一个,这个:www1.hkex.com.hk/hkexwidget/data/…
-
啊,如果找不到网络调用,最好的办法是使用 BeautifulSoup (crummy.com/software/BeautifulSoup/bs4/doc) 之类的工具来抓取页面并从 html 中提取表格信息。
-
问题是 HTML 没有数据,数据位于我试图访问的 .JSON 中
-
页面 (hkex.com.hk/Market-Data/Securities-Prices/Equities?sc_lang=en) 的 HTML 似乎确实在
table->tr->td标记中包含数据。
标签: python json python-3.x web-scraping