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.26 KB | None | 0 0
  1. import time
  2. import cloudscraper
  3. import fake_useragent
  4. from requests_toolbelt.multipart.encoder import MultipartEncoder
  5. import codecs
  6.  
  7. proxies = [
  8.     'http://1d4
  9.  
  10. ]
  11.  
  12. board = 'b'
  13. thread = '285388350'
  14. fileObj = codecs.open('text.txt', 'r', "utf_8_sig")
  15. comment = fileObj.read()
  16. fileObj.close()
  17. s = cloudscraper.CloudScraper()
  18.  
  19.  
  20. def get_new_useragent():
  21.    return fake_useragent.UserAgent().random
  22.  
  23.  
  24. def get_new_proxy(proxy):
  25.    s.proxies = {"http": proxy, "https": proxy}
  26.  
  27.  
  28. def get_captcha_id():
  29.    res = s.get("https://2ch.hk/api/captcha/2chcaptcha/id?board=" + board + "&thread=" + thread)
  30.    print(res.text)
  31.    return res.json()['id']
  32.  
  33.  
  34. def get_captcha_value(id):
  35.    captchaget = s.get("https://2ch.hk/api/captcha/2chcaptcha/show?id=" + captcha_id)
  36.    print(captchaget.text)
  37.    img = open('captcha.jpg', 'wb')
  38.    img.write(captchaget.content)
  39.    return input('Введите капчу: ')
  40.  
  41.  
  42. def post():
  43.    response = s.post('https://2ch.hk/user/posting', data=mp_encoder, headers={'Content-Type': mp_encoder.content_type})
  44.    print(response.text)
  45.    if response.json()['result'] == 1:
  46.        print('Пост отправлен')
  47.  
  48.  
  49. while True:
  50.    start = time.time()
  51.    for i in proxies:
  52.        get_new_proxy(i)
  53.        try:
  54.            captcha_id = get_captcha_id()
  55.        except Exception as e:
  56.            print('Ошибка прокси, капчи', e)
  57.            continue
  58.        mp_encoder = MultipartEncoder(
  59.            fields={
  60.                "task": "post",
  61.                "board": board,
  62.                "thread": thread,
  63.                "usercode": "",
  64.                "code": "",
  65.                "captcha_type": "2chcaptcha",
  66.                "email": "sage",
  67.                "comment": comment,
  68.                "oekaki_image": "",
  69.                "oekaki_metadata": "",
  70.                "2chcaptcha_value": get_captcha_value(captcha_id),
  71.                "2chcaptcha_id": captcha_id,
  72.                "makaka_id": "",
  73.                "makaka_answer": ""
  74.            }
  75.        )
  76.        try:
  77.            post()
  78.        except Exception as e:
  79.            print('Ошибка постинга', e)
  80.    delay = time.time() - start
  81.    print(delay)
  82.    if delay < 20:
  83.        time.sleep(20 - delay)
  84.  
Add Comment
Please, Sign In to add comment