[英]How to download Flickr images using photos url (does not contain .jpg, .png, etc.) using Python
I want to download image from Flickr using following type of links using Python: https://www.flickr.com/photos/66176388@N00/2172469872/ https://www.flickr.com/photos/clairity/798067744/ I want to download image from Flickr using following type of links using Python: https://www.flickr.com/photos/66176388@N00/2172469872/ https://www.flickr.com/photos/clairity/798067744/
This data is obtained from xml file given at https://snap.stanford.edu/data/web-flickr.html此数据来自https://snap.stanford.edu/data/web-flickr.html中给出的 xml 文件
Is there any Python script or way to download images automatically.是否有任何 Python 脚本或自动下载图像的方法。
Thanks.谢谢。
I try to find answer from other sources and compiled the answer as follows:我尝试从其他来源找到答案并将答案编译如下:
import re
from urllib import request
def download(url, save_name):
html = request.urlopen(url).read()
html=html.decode('utf-8')
img_url = re.findall(r'https:[^" \\:]*_b\.jpg', html)[0]
print(img_url)
with open(save_name, "wb") as fp:
fp.write(request.urlopen(img_url).read())
download('https://www.flickr.com/photos/clairity/798067744/sizes/l/', 'image.jpg')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.