【发布时间】:2020-01-04 22:20:55
【问题描述】:
这是我的代码:
import requests
from bs4 import BeautifulSoup
r = requests.get('https://www.reddit.com/r/memes/')
soup = BeautifulSoup(r.content,'html.parser')
post = soup.find_all('img',attr={'alt:Post image'})
输出是[],但我不知道为什么。
【问题讨论】:
-
因为你的 attr 参数不是字典,它是一个集合。
标签: python web-scraping beautifulsoup