我无法从网站上抓取图片www.kissmanga.com. 我用的是Python3和Requests和Beautifulsoup库。刮掉的图像标签显示空白的“src”。在
源代码:
from bs4 import BeautifulSoup
import requests
scraper = cfscrape.create_scraper()
url = "http://kissmanga.com/Manga/Bleach/Bleach-634--Friend-004?id=235206"
response = requests.get(url)
soup2 = BeautifulSoup(response.text, 'html.parser')
divImage = soup2.find('div',{"id": "divImage"})
for img in divImage.findAll('img'):
print(img)
response.close()
我认为图像抓取是被阻止的,因为我相信网站使用了cloudflare。基于这个假设,我还尝试使用“cfscrape”库来获取内容。在
您需要等待
JavaScript
为图像注入html
代码。在有多种工具可以做到这一点,以下是其中一些工具:
我能让它和硒一起工作:
如果您还想下载这些图像,请参阅How to download image using requests。在
你试过设置custom user-agent吗? 这样做通常被认为是不道德的,但刮漫画也是如此。在
相关问题 更多 >
编程相关推荐