python爬虫拿取短信验证码登录_Python 爬虫验证码登录

# -*- coding: utf-8 -*-

import scrapy

from scrapy.http import Request,FormRequest

import urllib.request

class DbSpider(scrapy.Spider):

name = 'db'

allowed_domains = ['douban.com']

#start_urls = ['http://www.douban.com/']

header = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)'}

def start_requests(self):

return [Request('http://www.douban.com/accounts/login',headers=self.header,meta={'cookiejar':1},callback=self.parse)]

def parse(self, response):

authentication=response.xpath('//img[@id="captcha_image"]/@src').extract()

print(authentication )

if len(authentication )>0 :

urllib.request.urlretrieve(authentication [0],filename='yzm.png')

yzm=input('&g

你可能感兴趣的:(python爬虫拿取短信验证码登录_Python 爬虫验证码登录)