【发布时间】:2020-12-01 15:11:41
【问题描述】:
我的代码转到一个网站,提取 URL,然后转到它抓取的 URL(到这里都可以正常工作)
现在在这个新页面上,我想获取一些信息(作者姓名),但是它正在打印空白
代码如下:
from selenium import webdriver
from bs4 import BeautifulSoup
import time
import requests
driver = webdriver.Chrome()
eachLink=[]
baseurl='https://meetinglibrary.asco.org'
for x in range (1,2):
driver.get(f'https://meetinglibrary.asco.org/results?meetingView=2020%20ASCO%20Virtual%20Scientific%20Program&page={x}')
time.sleep(3)
page_source = driver.page_source
soup = BeautifulSoup(page_source,'html.parser')
productlist=soup.find_all('a',class_='ng-star-inserted')
for item in productlist:
for link in item.find_all('a',href=True):
eachLink.append(baseurl+link['href'])
print(eachLink)
infobox=[]
for b in eachLink:
r=requests.get(b)
time.sleep(1)
soup1=BeautifulSoup(r.content,'html.parser')
auth=soup1.find('a',class_='asset-metadata-value link ng-star-inserted')
print(auth)
【问题讨论】:
-
那么究竟是什么问题?
-
它在帖子中的字面意思是,它正在打印空白......
标签: python html web-scraping beautifulsoup