我已经解决了前面的问题。但现在我面临一个新问题。
当我在页面中搜索Sheeran时,if "Shreeran" in j:
一切都很好。但是,如果我再添加一个像concert这样的关键字,结果将随机生成。例如;if "Shreeran" or "concert" in j:
。我该怎么修?你知道吗
while True:
url ='https://xxxxxxxxx/{}'.format(pagenum)
driver.get(url)
pagesource = driver.page_source
soup = BeautifulSoup(pagesource, 'lxml')
if url == "https://xxxxxxxxxx/5":
break
else:
for s in soup.find_all("div", class_="_2cNsJna0_hV8tdMj3X6_gJ"):
for j in s:
if "Sheeran" in j: # only search Sheeran is fine but if i change it to "Sheeran" or "concert", the result will be generated randomly
print(s.text)
pagenum+=1
time.sleep(2)
我怎样才能用多个关键字搜索一些东西?你知道吗
另一种方法是找出网站在滚动时是如何获取内容的。你知道吗
您可以尝试在循环中增加页码。你知道吗
或者使用出现在网络流量中的API url。你知道吗
相关问题 更多 >
编程相关推荐