【发布时间】:2020-09-11 11:43:59
【问题描述】:
好的,对你们中的一些人来说应该很容易,但我找不到解决我这个问题的任何方法。我正在尝试从 NHL.com 上抓取一张表格,但它找不到任何表格 - 我尝试了“table”、“ReactTable”等任何东西。
import pandas as pd
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
from pandas_profiling import ProfileReport
import numpy as np
import matplotlib as plt
url = "http://www.nhl.com/stats/teams?report=goalsbyperiod&reportType=game&dateFrom=2020-03-11&dateTo=2020-09-11&gameType=3&filter=gamesPlayed,gte,1&sort=period1GoalsFor&page=0&pageSize=50"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
result = soup.find_all('table')
df_raw = pd.read_html(str(table))[0]
它只显示 ValueError: no tables found
相同的代码适用于我使用的大多数网站。请帮忙。
【问题讨论】:
-
页面有javascript在页面显示后加载数据...你需要从运行JS的浏览器实例开始,然后报废数据!
标签: python html pandas beautifulsoup python-requests