简体   繁体   English

如何使用 url(不包含 .jpg、.png 等)使用 Python 下载 Flickr 图像

[英]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.

相关问题 使用Flickr API下载图像— Python - Using Flickr API to download images — Python Python:需要从URL循环下载图像(JPG和PNG) - Python: Need to download images from URL in a loop (JPG and PNG) 如何从Python 3中的Flickr API下载Flickr中的照片 - How to download photos from Flickr by Flickr API in Python 3 如何从一组图像(.png,.jpg,.bmp等)中检索所有.txt格式(例如255、255、255)的原始rgb数据 - How do I retrieve all of the raw rgb data in .txt format (eg. 255, 255, 255) from a set of images (.png, .jpg, .bmp, etc.) 如何在 Windows 中使用 python 2.7 将 .raw 文件转换为 .jpg 或 .png - how to convert .raw file to .jpg or .png using python 2.7 in windows 如何使用 python 脚本将 eps 转换为 jpg 或 png - how to convert eps to jpg or png using python script 如何使用 python(EasyOCR、Tesseract 等)对简单数字进行 OCR? - How to OCR a simple digit using python (EasyOCR, Tesseract, etc.)? Python Selenium 使用 ChromeDriver 下载图像(jpeg、png)或 PDF - Python Selenium download images (jpeg, png) or PDF using ChromeDriver 在 python 中将图像 PNG 转换为 JPG - Converting Images PNG to JPG in python 使用python创建一个机器人以在9:00 am、10:00am等点击下载按钮 - Create a bot to click a download button at 9:00am, 10:00am, etc. using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM