我遇到了一个关于抓取ajax加载网站的主要问题。我在网上搜索以找到解决方案,并在开发人员模式下检查XHR。但是,当我试图在代码中使用查询字符串参数时,结果没有成功。谁能告诉我怎么做
XHR查询字符串参数如下所示:
/data/bbc-morph-lx-commentary-data-paged/about/1d62d302-53c9-4f79-b281-62993210e174/isUk/false/limit/20/nitroKey/lx-nitro/pageNumber/7/version/1.5.4?timeout=5
这是我的密码。它只从第一页中删除链接
url="https://www.bbc.com/news/topics/c87z0we2g0zt/coronavirus-vaccines"
data={'about':'','isUk':'','limit':'20','nitroKey':'lx-nitro','pageNumber':3,'version':''}
req=requests.session()
req=requests.get(url,params=data,headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'})
req_content=req.content
bsObj=BeautifulSoup(req_content, 'html5lib')
coverpage_news=bsObj.find_all("li",{"class": "lx-stream__post-container"})
for n in np.arange(0, 19):
# Getting the link of the article
link = "https://www.bbc.com"+coverpage_news[n].find("div",attrs={'class':'gs-o-media__body'}).find('a')['href'].strip()
list_links.append(link)
目前没有回答
相关问题 更多 >
编程相关推荐