【发布时间】:2020-03-25 17:10:12
【问题描述】:
在选择“HK Stock”和“Show All”按钮后,我尝试下载“https://www.bsgroup.com.hk/BrightSmart/MarginRatio/StockMarginRatioEnquiry.aspx?Lang=eng”中的表格。我检查了 Chrome/Inspect/Network 功能。没有向服务器发送新数据的请求。因此,我怀疑数据在原始页面中。按下“显示全部”按钮后,我检查了它是否出现在“表 1”中。试了下面的代码,还是没有出来,请指教:
url="https://www.bsgroup.com.hk/BrightSmart/MarginRatio/StockMarginRatioEnquiry.aspx?Lang=eng"
result = requests.get(url)
result.raise_for_status()
result.encoding = "utf-8"
src = result.content
soup = BeautifulSoup(src, 'lxml')
table = soup.findAll("Table1")
output_rows = []
for table_row in table.findAll('tr'):
columns = table_row.findAll('td')
output_row = []
for column in columns:
output_row.append(column.text)
output_rows.append(output_row)
print(output_rows)
【问题讨论】:
标签: python html-table beautifulsoup multipleselection