BeautifulSoup提取网页信息
网页源代码中需要提取的部分:<div id = "buttons">
<ul>
<!-- <li id = "reload"><a target = "_blank" href = "//sci-hub.tw/reload/10.1116/1.5134135">↻ reload</a></li>-->
<li><a href = # onclick = "location.href='//sci-hub.tw/downloads/2020-01-15/b9/10.1116@1.5134135.pdf?download=true'">⇣ save</a></li>
</ul>
url = 'https://www.sci-hub.tw/https://avs.scitation.org/doi/10.1116/1.5134135'
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, 'lxml')
pdf_url = soup.find('div', attrs={id: 'buttons'})
print(pdf_url)
用这个得不到想要的内容,哪里出问题了呢? attrs={'id': 'buttons'}
页:
[1]