【发布时间】:2018-12-22 12:25:23
【问题描述】:
我正在学习 BeautifulSoup 并尝试加载 this 网页的内容。我试图通过inspect element 深入了解HTML tags 来获取内容。
我使用不同的代码sn-ps来显示并检查我是否能够成功检索到内容。
以下代码 sn-ps 产生了很好的结果:
from bs4 import BeautifulSoup
import requests
root = 'https://www.quora.com/topic/Graduate-Record-Examination-GRE-1'
r = requests.get(root)
soup = BeautifulSoup(r.text,'html.parser')
#**The following worked yielded some results :**
#1
a = soup.find_all('div',{'class':'feed'})
print(a)
#2
b = soup.find_all('div',{'class':'ContentWrapper'})
print(b)
#3
c = soup.find_all('div',{'class':'ContentWrapper'})
print(c)
#4
d = soup.find_all('div',{'class':'feed'})
print(d)
#5
e = soup.find_all('div',{'class':'TopicFeed'})
print(e)
但是,在深入了解之后,以下内容并没有产生任何结果:
f = soup.find_all('div',{'class':'paged_list_wrapper'})
print(f)
打印:[]
<div class='paged_list_wrapper'> 内的内容/HTML 代码未打印。为什么?
【问题讨论】:
-
我确实通过
soup.find_all('div',{'class':'paged_list_wrapper'})获取信息。您确定要查看共享链接的响应吗?
标签: python html web-scraping beautifulsoup quora