我试图解析从本网站链接的意见“查看更多”选项数据: I need to get 1000 comments, by default it shows only 10如何刮去网站有使用BeautifulSoup图书馆在Python
我想1000层的意见,这表明只有10默认。我无法想出一个办法,点击“查看更多”
后能得到它显示在网页上的内容,我有以下代码uptil现在:
import urllib.request
from bs4 import BeautifulSoup
import sys
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
response = urllib.request.urlopen("https://www.mygov.in/group-issue/share-
your-ideas-pm-narendra-modis-mann-ki-baat-26th-march-2017/")
srcode = response.read()
soup = BeautifulSoup(srcode, "html.parser")
all_comments_div=soup.find_all('div', class_="comment_body");
all_comments=[]
for div in all_comments_div:
all_comments.append(div.find('p').text.translate(non_bmp_map))
print (all_comments)
print (len(all_comments))
你是如何试图点击“查看更多” ......硒,或者是你抓住“下一步” href和直接请求页面? – pbuck