我不知道如何将刮下的图像保存到桌面上的文件中。你知道吗
我试图从代码中列出的站点下载图像,但我只知道导入BeautifulSoup和Request之类的基础知识。我不明白每件事都意味着什么。你知道吗
from bs4 import BeautifulSoup
import urllib.request as request
folder = r'C:\Users\rlook\Desktop\scrape' + '\\'
url = "https://www.butterfliesofamerica.com/t/Phocides_belus_a.htm"
response = request.urlopen(url)
soup = BeautifulSoup(response, 'html.parser')
for res in soup.findAll('img')
我可以在其他网站上使用一些代码,但无法使其符合我的目的。enter code here
from urllib.request as request
from bs4 import BeautifulSoup
folder = r'C:\Users\rlook\Desktop\scrape' + '\\'
URL ='https://www.butterfliesofamerica.com/t/Phocides_belus_a.htm'
response = request.urlopen(URL)
soup = BeautifulSoup(response, 'html.parser')
iconTable = soup.find('a', {'class' : 'y'})
request.urlretrieve(icon.img['src'], folder + icon.img['alt'] + '.jpg')
我使用requests和beautifulsoup(以及re和shutil)来获得完整大小的图像,而不仅仅是缩略图。必须在命令行中
pip install requests
和pip install bs4
才能使用此解决方案。你知道吗代码
相关问题 更多 >
编程相关推荐