使用Python爬取WhaleWisdom上Renaissance Technologies持仓表获空数据问题
网页爬取拿到空表格数据的问题
用Python爬取指定页面的持仓表格时,最后拿到的表格内容是空的,提取不到有效数据。
现在用的实现代码如下:
import requests from bs4 import BeautifulSoup import lxml.html as lh from lxml.html.clean import clean_html url = "https://whalewisdom.com/filer/renaissance-technologies-llc#tabholdings_tab_link" response = requests.get(url) print(response) soup = BeautifulSoup(response.content, 'html.parser') doc = lh.fromstring(response.content, 'html.parser').xpath("//table[@id='current_holdings_table']") for i in doc: html_data = lh.tostring(i) print(html_data) #soup_table = doc.findAll('table', attrs={'id': 'current_holdings_table'})
跑这段代码的时候,通过XPath定位到ID为current_holdings_table的目标表格,打印出来的表格HTML根本没有持仓相关的有效信息,和网页上正常显示的表格内容对不上,运行结果可以看下面的截图:
内容的提问来源于stack exchange,提问作者Ramlakhan Kevat
相关产品推荐
相关产品推荐

