Flickr is Yahoo's image sharing website, which has a lot of wonderful pictures shared by netizens all over the world, and is considered a professional picture website. Its API is also friendly and can be implemented in a variety of functions. Here I used Python to invoke its API to get a lot of photo data.
First you need to go to Flickr to register as its developer, create apps, get Api_key and Api_secret, and its API URL in: https://www.flickr.com/services/api/
Flickr offers a variety of development tools to use. Here we use Python development tools. The official recommended development tool is the BEEJ's Python Flickr API. Https://stuvel.eu/flickrapi
Can be installed directly using the PIP installation tool, the input FLICKRAPI can be installed automatically.
Official documentation is here: https://stuvel.eu/flickrapi-doc/
The best way to crawl your photo data is to use its walk method. This method essentially calls the Flickr.photos.search interface, and various parameters can be found in the API description: https://www.flickr.com/services/api/flickr.photos.search.html
With this method, input different parameters, you can meet most of the data mining needs, including time, location, photo type.
A simple code is posted here for reference only:
1 #Coding:utf-82 ImportFlickrapi3 #enter the key and secret for the API4Flickr=Flickrapi. Flickrapi (Api_key,api_secret)5 Try:6 #crawl the text for ' New York ' photos, where you can set other parameters according to your needs7Photos=flickr.walk (text='New York', extras='Url_c')8 excepte:9 Print('Error')Ten forPhotoinchPhotos: One #get the URL of the photo, set the size to Url_c (see FLICKRAPI official documentation for specific parameters) AUrl=photo.get ('Url_c') - Print(str (URL))
It is important to note that, in the event of a loop, it is possible that the amount of data is too large, so you need to add some restrictions, such as a call to only call data over a period of time, and then batch mining data.
Use Python to invoke the Flickr API to fetch image data