Я действительно какое-то время был озадачен этим.
Ссылка на таблицу = https://en.wikipedia.org/wiki/List_of_Manchester_United_F.C._seasons
Я хочу получить данные в столбцах, выделенных красным цветом ниже
![enter image description here](https://i.stack.imgur.com/gVleM.png)
И поместите его в фрейм данных панд, как этот
![enter image description here](https://i.stack.imgur.com/lGMiU.png)
Вот мой код
import urllib.request
url = "https://en.wikipedia.org/wiki/List_of_Manchester_United_F.C._seasons"
page = urllib.request.urlopen(url)
from bs4 import BeautifulSoup
soup = BeautifulSoup(page, "lxml")
# print(soup.prettify())
my_table = soup.find('table', {'class':'wikitable sortable'})
season = []
data = []
for row in my_table.find_all('tr'):
s = row.find('th')
season.append(s)
d = row.find('td')
data.append(d)
import pandas as pd
c = {'Season': season, 'Data': data}
df = pd.DataFrame(c)
df
Вот мой вывод.Я совершенно заблудился о том, как добраться до простой таблицы из 5 столбцов выше.Спасибо ![enter image description here](https://i.stack.imgur.com/ZFvue.png)