Guest User

Untitled

a guest
Apr 8th, 2023
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.47 KB | None | 0 0
  1. import time
  2.  
  3. import cloudscraper
  4. import fake_useragent
  5. from requests_toolbelt.multipart.encoder import MultipartEncoder
  6. import random
  7.  
  8. noproxies = 0  # input('no-proxies: 1(без прокси) или 0(с прокси): ')
  9. proxies = [
  10.    
  11.  
  12. ]
  13. # board = input('Введите доску: ')
  14. # thread = input('Введите тред: ')
  15. # comment = input('Введите сообщение: ')
  16. board = 'b'
  17. thread = '285356430'
  18. comment = 'галава дай денег'
  19. s = cloudscraper.CloudScraper()
  20.  
  21.  
  22. def get_new_useragent():
  23.     return fake_useragent.UserAgent().random
  24.  
  25.  
  26. def get_new_proxy():
  27.     proxy = random.choice(proxies)
  28.     s.proxies = {"http": proxy, "https": proxy}
  29.     return proxy
  30.  
  31.  
  32. def get_captcha_id():
  33.     res = s.get("https://2ch.hk/api/captcha/2chcaptcha/id?board=" + board + "&thread=" + thread)
  34.     print(res.text)
  35.     return res.json()['id']
  36.  
  37.  
  38. def get_captcha_value(captcha_id):
  39.     captchaget = s.get("https://2ch.hk/api/captcha/2chcaptcha/show?id=" + captcha_id)
  40.     print(captcha_id)
  41.     img = open('captcha.jpg', 'wb')
  42.     img.write(captchaget.content)
  43.     return input('Введите капчу: ')
  44.  
  45.  
  46. def post():
  47.     response = s.post('https://2ch.hk/user/posting', data=mp_encoder, headers={'Content-Type': mp_encoder.content_type})
  48.     print(response.text)
  49.     return response.json()['result']
  50.  
  51.  
  52. while True:
  53.     if noproxies == 0:
  54.         IP = get_new_proxy()
  55.     try:
  56.         captcha_id = get_captcha_id()
  57.     except Exception as e:
  58.         print('Ошибка подключения '+e)
  59.         if noproxies == '0':
  60.             print('Ошибка прокси', IP, proxies)
  61.             IP = get_new_proxy()
  62.         continue
  63.     mp_encoder = MultipartEncoder(
  64.         fields={
  65.             "task": "post",
  66.             "board": board,
  67.             "thread": thread,
  68.             "usercode": "",
  69.             "code": "",
  70.             "captcha_type": "2chcaptcha",
  71.             "email": "",
  72.             "comment": comment,
  73.             "oekaki_image": "",
  74.             "oekaki_metadata": "",
  75.             "2chcaptcha_value": get_captcha_value(captcha_id),
  76.             "2chcaptcha_id": captcha_id,
  77.             "makaka_id": "",
  78.             "makaka_answer": ""
  79.         }
  80.     )
  81.     if post() == 1:
  82.         #time.sleep(20)
  83.         print('заебись')
  84.     else:
  85.         print('Ошибка постинга')
  86.         if noproxies == 0:
  87.             print('Ошибка прокси', IP)
  88.             IP = get_new_proxy()
  89.  
Add Comment
Please, Sign In to add comment