Python爬取图片验证码

# -*- coding:utf-8 -*-
import requests
from bs4 import BeautifulSoup

header = {
  'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'
}
url = 'https://www.anjuke.com/v3/ajax/captcha/newimage?id='
for i in range(1, 1000):
    image = requests.get(url, headers=header).content
    with open(str(i)+'image.jpg', 'wb') as f:
        f.write(image)

你可能感兴趣的:(Python,爬虫,python,验证码)