Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import cloudscraper
- import fake_useragent
- from requests_toolbelt.multipart.encoder import MultipartEncoder
- import codecs
- proxies = [
- 'http://1d4
- ]
- board = 'b'
- thread = '285388350'
- fileObj = codecs.open('text.txt', 'r', "utf_8_sig")
- comment = fileObj.read()
- fileObj.close()
- s = cloudscraper.CloudScraper()
- def get_new_useragent():
- return fake_useragent.UserAgent().random
- def get_new_proxy(proxy):
- s.proxies = {"http": proxy, "https": proxy}
- def get_captcha_id():
- res = s.get("https://2ch.hk/api/captcha/2chcaptcha/id?board=" + board + "&thread=" + thread)
- print(res.text)
- return res.json()['id']
- def get_captcha_value(id):
- captchaget = s.get("https://2ch.hk/api/captcha/2chcaptcha/show?id=" + captcha_id)
- print(captchaget.text)
- img = open('captcha.jpg', 'wb')
- img.write(captchaget.content)
- return input('Введите капчу: ')
- def post():
- response = s.post('https://2ch.hk/user/posting', data=mp_encoder, headers={'Content-Type': mp_encoder.content_type})
- print(response.text)
- if response.json()['result'] == 1:
- print('Пост отправлен')
- while True:
- start = time.time()
- for i in proxies:
- get_new_proxy(i)
- try:
- captcha_id = get_captcha_id()
- except Exception as e:
- print('Ошибка прокси, капчи', e)
- continue
- mp_encoder = MultipartEncoder(
- fields={
- "task": "post",
- "board": board,
- "thread": thread,
- "usercode": "",
- "code": "",
- "captcha_type": "2chcaptcha",
- "email": "sage",
- "comment": comment,
- "oekaki_image": "",
- "oekaki_metadata": "",
- "2chcaptcha_value": get_captcha_value(captcha_id),
- "2chcaptcha_id": captcha_id,
- "makaka_id": "",
- "makaka_answer": ""
- }
- )
- try:
- post()
- except Exception as e:
- print('Ошибка постинга', e)
- delay = time.time() - start
- print(delay)
- if delay < 20:
- time.sleep(20 - delay)
Add Comment
Please, Sign In to add comment