【发布时间】:2021-05-25 17:53:24
【问题描述】:
import requests
from bs4 import BeautifulSoup
import pandas as pd
url = "https://www.pivottrading.co.in/beta/tools/open-high-low-scanner.php?broker=zerodha"
page = requests.get(url)
soup = BeautifulSoup(page.text, 'lxml')
table = soup.find('table', {'class' : 'table'})
rows = table.find_all('th')
headers = []
for i in table.find_all('th'):
title = i.text
headers.append(title)
df = pd.DataFrame(columns = headers)
for row in table.find_all('tr')[1:]:
data = row.find_all('td')
row_data = [td.text.strip() for td in data]
length = len(df)
df.loc[length] = row_data
print(df)
我需要从网站上抓取一个表格,但它已选中每一行的所有复选框。我该怎么办。 任何帮助将不胜感激。
【问题讨论】:
-
欢迎来到 SO!我无法理解你的问题。你到底想刮什么?什么是预期的输出? “我需要从网站上抓取一个表格,但它为每一行选中了所有复选框”这到底是什么意思?
标签: python pandas beautifulsoup