|
10鱼币
我想要进里 https://www.gia.edu/CN/report-check?reportno=6352100549 爬数据,但是有验证码 https://data.gia.edu/RDWB/Captch ... CN&APIno=1& 。
我想把验证码以图片的格式保存下来,然后 连接到打码平台。
但是为什么我保存下来的不是图片格式。
原代码:
————————————————————————————
from urllib.request import Request,urlopen
import re
url = 'https://data.gia.edu/RDWB/Captcha.jsp?reportno=6352100549&cc=CN&APIno=1&'
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.55 Safari/537.36'
}
request = Request(url,headers=headers)
response = urlopen(request).read()
name='good'
with open(name,'wb') as f:
img = response
a=f.write(img)
————————————————————————————————
你的url就不对,爬下来的是html数据,怎么保存为图片?而且保存时图片后缀也没写。。。。。。。。。。。。。
换这个url才行
- from urllib.request import Request,urlopen
- import re
- url = 'https://data.gia.edu/RDWB/botdetectcaptcha?get=image&c=jqueryBasicCaptcha&t=b2986c492e4141c4b5fc4cd8f6b0396f'
- headers = {
- 'User-Agent':'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.55 Safari/537.36',
- 'referer': 'https://data.gia.edu/RDWB/Captcha.jsp?reportno=6352100549&cc=CN&APIno=1&'
- }
- request = Request(url,headers=headers)
- response = urlopen(request).read()
- print(response)
- name='good.png'
- with open(name,'wb') as f:
- img = response
- a=f.write(img)
复制代码
|
最佳答案
查看完整内容
你的url就不对,爬下来的是html数据,怎么保存为图片?而且保存时图片后缀也没写。。。。。。。。。。。。。
换这个url才行
|