Python脚本:用于获取单一或多张图片
发布时间
阅读量:
阅读量
获取单一图像:
#pics.py
"""this is for catching pictures"""
import requests
import re
from bs4 import BeautifulSoup
def catch_onepicture(url,headers):
response = requests.get(url=url,headers=headers)
html = response.text
soup = BeautifulSoup(html,'lxml')
links = soup.find_all('a',class_='mainphoto')
pattern = '<img src="(.*?)" width="457"/>'
link = re.findall(string=str(links[0]),pattern=pattern)
return link[0]
全部评论 (0)
还没有任何评论哟~
