Python爬取图片项目介绍
第三方库:requests,fake_useragent(产生随机请求头进行访问)
代码实现:
import requests
from fake_useragent import UserAgent
filename=0
class photo_spider(object):
def __init__(self):
self.url = 'https://api.500px.com/v1/photos?rpp=50&feature=popular&image_size%5B%5D=1&image_size%5B%5D=2&image_size%5B%5D=32&image_size%5B%5D=31&image_size%5B%5D=33&image_size%5B%5D=34&image_size%5B%5D=35&image_size%5B%5D=36&image_size%5B%5D=2048&image_size%5B%5D=4&image_size%5B%5D=14&sort=&include_states=true&include_licensing=true&formats=jpeg%2Clytro&only=&exclude=&personalized_categories=&page={}&rpp=50'
ua = UserAgent(verify_ssl=False)
# 产生随机的UserAgent请求头进行访问。
for i in ra