抓取:无法从网页中提取内容

问题描述

我正在尝试从下一页抓取新闻内容,但没有成功。 https://www.business-humanrights.org/en/latest-news/?&search=nike

我尝试过Beautifulsoup

r = requests.get("https://www.business-humanrights.org/en/latest-news/?&search=nike")
soup = BeautifulSoup(r.content,'lxml')
soup

但是我要查找的内容-标记为div class ='card__content'的新闻片​​段没有出现在汤输出中。

我也检查过,但找不到要切换到的帧。

最后,我尝试使用phantomjs和以下代码,但未成功:

import time
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

url = "https://www.business-humanrights.org/en/latest-news/?&search=nike"
driver = webdriver.PhantomJS(executable_path= '~\Chromedriver\phantomjs-2.1.1-windows\bin\phantomjs.exe')

driver.get(url)
time.sleep(7)
page = driver.page_source
driver.quit()
soup = BeautifulSoup(page,'html.parser')
container = soup.find_all('div',attrs={
    'class':'card__content'})
print(container)

我的选件已用完,任何人都可以提供帮助?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)