0
import urllib2
from bs4 import BeautifulSoup
url = 'https://www.wsj.com/news/world'
page = urllib2.urlopen(url)
soup = BeautifulSoup(page, 'html.parser')
l = soup.find_all('div', {'class': 'module module_ls ls ni noImage'})
a = soup.find_all('a', {'class': 'subPrev headline'})
print(l)
print(a)
这会返回空列表。但正如你可以在图像中看到的那样,这些类存在div ......为什么?BS4找不到元素
谢谢,但它也不工作。对你起作用吗? – ben
没有。这很奇怪。 – phd
哈哈,是啊,这真是太痛苦了 – ben