【发布时间】:2019-04-07 14:11:15
【问题描述】:
我正在尝试使用 beautiful soup 从this web page 下载投票意向民意调查列表。但是,我编写的代码返回一个空数组或什么都不返回。我使用的代码如下:
页面代码是这样的:
<div class="ST-c2-dv1 ST-ch ST-PS" style="width:33px"></div>
<div class="ST-c2-dv2">41.8</div>
这就是我尝试过的:
import requests
from bs4 import BeautifulSoup
request = requests.get(quote_page) # take the page link
page = request.content # extract page content
soup = BeautifulSoup(page, "html.parser")
# extract all the divs
for each_div in soup.findAll('div',{'class':'ST-c2-dv2'}):
print each_div
此时,它什么也不打印。 我也试过这个:
tutti_a = soup.find_all("html_element", class_="ST-c2-dv2")
还有:
tutti_a = soup.find_all("div", class_="ST-c2-dv2")
但是我得到一个空数组 [] 或者什么都没有
【问题讨论】:
标签: python-3.x web-scraping beautifulsoup