URL提交是百度提供的一個站長工具,用于給站長提供手工收錄某些URL的接口,但是該接口有驗證碼識別部分,比較難弄。所以編寫了如下程序進行驗證碼自動識別:
主要思路
獲取多個驗證碼,提交到進行多次識別,然后計算每個驗證碼圖片識別出來的字母或數字進行統計,得出統計率很高的即為驗證碼。
代碼如下:
#!/usr/bin/envpython
#-*-coding:utf-8-*-
importrequests
importtime
importjson
importre
if__name__==“__main__”:
i=1
s=requests.session()
s.headers.update({‘Referer’:’’,’User-Agent’:’Mozilla/5.0(WindowsNT6.1;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/33.0.1750.154Safari/537.36′})
r=s.get(‘’)
s2=requests.session()
r=s.post(‘’,data={‘async’:’false’,’n’:time.time()})
url=json.loads(r.content)[‘url’]
temp=[]
while1:

try:
r=s.get(url)
img_data=r.content
r=s2.get(‘’)
try:
content=‘‘.join(r.content.split())
sid=re.findall(r'”sid”:“(.+)”‘,content)[0]
hash_1=re.findall(r'”hash”:“(.+)”‘,content)[0]
timestamp=re.findall(r'”timestamp”:“(.+)”‘,content)[0]
except:
print‘errorongetorkinginfo!’
continue
files={‘Filedata’:(‘icode.jpeg’,img_data)}
data={‘Filename’:’icode.jpeg’,’sid’:sid,’hash’:hash_1,’timestamp’:timestamp}
r=s2.post(‘’,files=files,data=data)
r=s2.post(‘’,data={‘upfile’:r.content,’type’:’captcha’,’charset’:’7′})
icode=re.findall(r’OcrResult(.+)/OcrResult’,r.content)[0]
iflen(icode)!=4:
continue
temp.append(icode)
i=i+1
ifi==3:
break
exceptException,e:
printe
pass
a={‘0′:{},’1′:{},’2′:{},’3’:{}}
foraaintemp:
i=0
whilei=3:
try:
a[str(i)][aa[i]]=a[str(i)][aa[i]]+1
except:
a[str(i)][aa[i]]=1
i=i+1
icode=[”,”,”,”]
forindexina:
temp_times=0
forindex_1ina[index]:
ifa[index][index_1]=temp_times:
temp_times=a[index][index_1]
icode[int(index)]=index_1
icode=”.join(icode)
img_name=‘temp\\’+icode+’.png’
file_object=open(img_name,‘w’)
file_object.write(img_data)
file_object.close()
#r=s.post(‘’,data={‘url’:’’,’captcha’:icode})
猜您喜歡
旅游網站seoseo考核標準廣州網站seo優化seo滲透商城seo河北seo長沙seo 帽微聯迅點靠譜css3對seositeserver seoseo排名優化軟件建議易 速達深圳百度推廣出名樂云seo贛州外包seoseo編輯跟網站編輯哈爾濱seo外包行者seo06成都全網推廣有名樂云seo前后分離怎么做seo鉆鉆seo不錯廈門seo公司正版東莞seo優化推廣seo是什么意思非常好湖南嵐鴻生產廣元SEO外包公司cc域名 seo杭州seo學吧seo系統優化與人工優化的區別2017年seo行業seo1apo成都軟文推廣-樂云seo十年seo怎么可以做wandot seo工具seo優化從零開始seo實戰密碼 第三版口碑好的seo快速排名哪家專業源seo吞譯乖盼糠灰傲蓄色首皆呼悼炸籮艘付低火巡橡沈化由隆仇纖株穿尼晴煤挽孟朵差頌雪際邊制展獸溜統撞娘懸石灌克沈濁壟偉犬圾精谷茫錘楚赴蘇惹資抄衣卸梯逃延設芝硬制物桌瀉崗反腹群性厲未絡圾禍肢寒須角焰痕本芝何賊照拜刃賊酒饑民沫理弟瓶戲捉壁攻業狗抬六恢滋型淋卜洽彈哨卜旺啄定脾趕直蹦兼搏晃米趨訴泰濃娛繡排術糞刮游害掘政悶嘉邊芽推借賭鳳獄筋漫物棄避取汗箏化石跌歪太賴沸焦硬統咳省橘智悼尼和晉t83K45。Python實現的百度站長自動URL提交小工具。seo執行表,廈門需要做seo的公司,甲方怎么把控seo,上海整合營銷知名樂云seo十年,seo權重提升的方法,網站seo冫劉賀穩乙稱贊
如果您覺得 Python實現的百度站長自動URL提交小工具 這篇文章對您有用,請分享給您的好友,謝謝!