daniilak

Untitled

Feb 27th, 2022 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import requests
  2. from time import time
  3.  
  4. KAD_HEAD={
  5.  
  6.     'Host': 'kad.arbitr.ru',
  7.     'Connection': 'keep-alive',
  8.     'Pragma': 'no-cache',
  9.     'Cache-Control': 'no-cache',
  10.     'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="98", "Google Chrome";v="98"',
  11.     'Accept':'application/json, text/javascript, */*',
  12.     'DNT': '1',
  13.     'X-Requested-With': 'XMLHttpRequest',
  14.     'sec-ch-ua-mobile': '?0',
  15.     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36',
  16.     'sec-ch-ua-platform': '"Windows"',
  17.     'Sec-Fetch-Site': 'same-origin',
  18.     'Sec-Fetch-Mode': 'cors',
  19.     'Sec-Fetch-Dest': 'empty',
  20.     'Referer': 'https://kad.arbitr.ru/',
  21.     'Accept-Encoding': 'gzip, deflate, br',
  22.     'Accept-Language': 'ru',
  23. }
  24.  
  25. class ParserKad:
  26.     def __init__(self, request_json=None) -> None:
  27.        
  28.         self.json_data = request_json if request_json else None
  29.        
  30.  
  31.     def is_need_show_captcha(self):
  32.         try:
  33.             r = requests.get(
  34.                 'https://kad.arbitr.ru/Recaptcha/IsNeedShowCaptcha?_=' +
  35.                 str(int(time() * 1000)),
  36.                 headers=KAD_HEAD,
  37.                 #proxies=self.proxies,
  38.                 #cookies=self.cookies
  39.             )
  40.         except Exception as e:
  41.             return True
  42.        
  43.         print(r.text)
  44.  
  45.         try:
  46.             return r.json()['Result']
  47.         except Exception as e:
  48.             return True
  49.  
  50.     def search(self, index=0):
  51.         while index < 10:
  52.             el = self.is_need_show_captcha()
  53.             print('el', el)
  54.             exit()
  55.            
  56.  
  57. c = ParserKad()
  58. c.search()
Add Comment
Please, Sign In to add comment