我是网络抓取的新手,想从 Spotrac 抓取大学项目的球员姓名和薪水。到目前为止,我所做的如下。
import requests
from bs4 import BeautifulSoup
URL = 'https://www.spotrac.com/nfl/rankings/'
reqs = requests.get(URL)
soup = BeautifulSoup(reqs.text, 'lxml')
print("List of all the h1, h2, h3 :")
for my_tag in soup.find_all(class_="team-name"):
print(my_tag.text)
for my_tag in soup.find_all(class_="info"):
print(my_tag.text)
Run Code Online (Sandbox Code Playgroud)
这个输出只有 100 个名字,但页面有 1000 个元素。有没有原因造成这种情况?