try:
elem3 = driver.find_element(By.ID, 'post_field')
text = open('text.txt','r').read()
elem3.send_keys(text)
driver.find_element(By.ID, 'send_post').click()
except:
cap = driver.find_element(By.CLASS_NAME, 'captcha')
cap2 = driver.find_element(By.TAG_NAME, 'img')
src = cap2.get_attribute('src')
res = requests.get(src)
ran = random.randint(0,1000000000000000000)
fp = open(f'captcha_{str(ran)}.jpg', 'wb')
fp.write(res.content)
files = {'file': fp}
t = requests.post('http://rucaptcha.com/in.php?key=здесь был токен&method=post',files=files)
captcha = t.text[3:]
print(captcha)
fp.close()
sleep(3)
est = requests.post(f'http://rucaptcha.com/res.php?key=здесь был токен&action=get&id={captcha}')
while est.text != 'CAPCHA_NOT_READY':
if est.text != 'CAPCHA_NOT_READY':
print(est.text[3:])
break
sleep(3)
driver.find_element(By.CLASS_NAME, 'big_text').send_keys(est.text[3:])
driver.find_element(By.CLASS_NAME, 'big_text').send_keys(Keys.ENTER)
Traceback (most recent call last):
File "c:\Users\Максим\Desktop\vk-spamer-free\spam.py", line 60, in <module>
t = requests.post('http://rucaptcha.com/in.php?key=здесь был токен&method=post',files=files)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 573, in request
prep = self.prepare_request(req)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 484, in prepare_request
p.prepare(
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 371, in prepare
self.prepare_body(data, files, json)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 556, in prepare_body
(body, content_type) = self._encode_files(files, data)
File "C:\Users\Максим\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 191, in _encode_files
fdata = fp.read()
io.UnsupportedOperation: read
Как исправить?