Python 尝试使用BeautifulSoup提取所有艺术家的名字

Python 尝试使用BeautifulSoup提取所有艺术家的名字,python,html,web-scraping,beautifulsoup,python-requests,Python,Html,Web Scraping,Beautifulsoup,Python Requests,我最近开始使用BeautifulSoup进行网页抓取。我正试图从美国国家美术馆的第一页摘录所有艺术家的名字 这是我的代码 import requests from bs4 import BeautifulSoup data=requests.get('https://www.nga.gov/Collection/artists.html?pageNumber=1') soup=BeautifulSoup(data.content,'html.parser') soup.find_all(

我最近开始使用BeautifulSoup进行网页抓取。我正试图从美国国家美术馆的第一页摘录所有艺术家的名字

这是我的代码

import requests

from bs4 import BeautifulSoup

data=requests.get('https://www.nga.gov/Collection/artists.html?pageNumber=1')

soup=BeautifulSoup(data.content,'html.parser')

soup.find_all('a')
当我这样做时,我会得到页面中所有的链接,除了包含艺术家姓名的链接

例如,对于艺术家“希腊A”工厂,这是在Chrome“”中使用inspect选项后找到的标签 但是在我创建的soup对象中找不到这个。 你能告诉我我犯了什么错误吗?

试试这个:

from selenium import webdriver
from bs4 import BeautifulSoup
import time

driver = webdriver.Chrome()
driver.get('https://www.nga.gov/Collection/artists.html?pageNumber=1')
time.sleep(5)
soup = BeautifulSoup(driver.page_source,'lxml')
driver.quit()

for artist_name in soup.select('.title a'):
    print(artist_name.text)
部分结果:

"Greek A" Factory
2 Bit Comics
7 Freds Press
A. B.
Aachen, Hans von
Aarland, Johann Carl Wilhelm
Abakanowicz, Magdalena

ul类中的数据返回具有超链接引用文本的
,工厂具有动态内容。这是一个相关的例子