def login_after_captcha(self, response):
with open('captcha.jpg', 'wb') as f:
f.write(response.body)
f.close()
from PIL import Image
try:
img = Image.open('captcha.jpg')
img.show()
img.close()
except:
pass
captcha = input('??????')
post_data = response.meta.get('post_data', {})
post_url = 'https://www.zhihu.com/login/phone_num'
post_data['captcha'] = captcha
return scrapy.FormRequest(post_url, formdata=post_data, headers=self.headers, callback=self.check_login)
评论列表
文章目录