【发布时间】:2016-06-05 14:55:36
【问题描述】:
我正在尝试从我的网页中获取所有具有 class= "thumb" 的缩略图的 URL,但 soup.find_all 只打印最近的 22 个左右。
代码如下:
import requests
from bs4 import BeautifulSoup
r = requests.get("http://rayleighev.deviantart.com/gallery/44021661/Reddit")
soup = BeautifulSoup(r.content, "html.parser")
links = soup.find_all("a", {'class' : "thumb"})
for link in links:
print(link.get("href"))
【问题讨论】:
-
据我所知,链接页面上有 24 个这样的链接。所以我猜代码工作正常。
标签: python python-3.x beautifulsoup python-requests