国产普通化妆品备案信息和进口普通化妆品备案信息查询
搞不懂为什么手动查输入一个号查一次就算了,为啥到详情了还要输入验证码,真用户体验有点差,
下面长话短说
涉及了两个接口
xxxxInfo和xxxxInfoHis
俩个接口都会返回数据,但返回的数据有细微差别,存在部分字段缺失或者字段数据多的情况,如果没仔细看就被坑了,太细了,一不小心就白折腾
国产特殊化妆品和进口特殊化妆品查询,也有这个问题,要注意
同时,detail_id,不同的itemid返回的也不是一个,有的f0,有的f1,有的f3,f4,哎,坑坑坑,挺多,不注意细节还真就不行
至于英数验证码,直接使用dddd就能过,通过率挺高的,简直无敌
cookie短时间能复用
最后也没啥难的了,就想办法遍历就行了,比app数据要全要多的多
def get_captcha(self):
for i in range(100):
try:
headers = {
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
"sec-ch-ua": "\"Google Chrome\";v=\"119\", \"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\""
}
res = self.sess.get("https://xxxxcha", headers=headers,
timeout=30,
proxies=self.proxy)
print(f"get_captcha {i} ", res.status_code)
if res and res.status_code == 200:
tree = res.json()
captchaKey = tree.get("captchaKey")
base64Img = tree.get("base64Img")
code = self.verify_cap(base64Img)
if code:
return captchaKey, code
else:
continue
elif res.status_code == 412:
self.get_cookie(res.text)
# time.sleep(2)
else:
self.sess = requests.session()
self.proxy = get_proxy()
except Exception as e:
print(e)
self.proxy = get_proxy()
time.sleep(2)
def query(self,prodId):
url11 = "xxxInfo" if xxx else "https://xxxInfoHis"
captcha_key, code = self.get_captcha()
for i in range(100):
try:
data = {
"prodId": prodId,
"gb": self.type,
"token": captcha_key,
"dataCode": code
}
data = json.dumps(data, separators=(',', ':'))
response = self.sess.post(url11, headers=self.headers, data=data, timeout=30)
print(f"query {i} ", response.status_code)
if response.status_code == 200:
rrr = response.text
if rrr and "验证码错误" in rrr:
captcha_key, code = self.get_captcha()
continue
else:
return response.json()
elif response.status_code == 412:
self.get_cookie(response.text)
# time.sleep(2)
else:
self.sess = requests.session()
self.proxy = get_proxy()
except Exception as e:
self.proxy = get_proxy()
time.sleep(2)