Python使用网络抓包的方式,利用超级鹰平台识别验证码登录,《爬取古诗文网》。
上篇–识别验证码
序言:
哈喽,各位小可爱们,我又来了,这次我新学习到的内容是python爬虫识别验证码。我这次用的是网络抓包工具来爬取,就是直接使用Requests模块进行抓取数据,除此之外还需要借助超级鹰平台进行验证码识别。
废话不多说,直接上代码:
import time
import requests
from chaojiying import Chaojiying_Client
time1=str(int(time.time()*1000))
url="https://so.gushiwen.cn/RandCode.ashx?"
f_url=url+time1
headers={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"}
params={
"t":time1}
response=requests.get(url=url,headers=headers,params=params)
img=response.content
with open("img.jpg","wb")