Closed ZeynX92 closed 2 years ago
@ZeynX92, да, стоит попробовать сбросить юзер-агент.
У меня вот почему-то опять всё работает.
Но если я напишу названия заголовков маленькими буквами
(host: и user-agent: вместо Host: и User-Agent:),
то клаудфлэр будет выдавать 403 Forbidden.
I think Cloudflare blocks requests from repl.it due to incorrect headers or IP address explained in https://github.com/DarkCat09/python-aternos/issues/16 by @sleeyax (thanks). Try to change the REQUA field:
Ok, I'll test this out. Also, what is "yourcookies" defined as?
I am using repl.it because I'm creating a wrapper for this project which is hosted on a Flask application. To make it public, I am using my existing pro subscription to replit.
@ZeynX92, да, стоит попробовать сбросить юзер-агент.
У меня вот почему-то опять всё работает. Но если я напишу названия заголовков маленькими буквами (host: и user-agent: вместо Host: и User-Agent:), то клаудфлэр будет выдавать 403 Forbidden
Понял, а как это сделать? + повторяю вопрос от человека выше)
yourcookies
is ATERNOS_SESSION cookie from your browser. E.g.: from_session('123AbC456yjdt')
как это сделать
Use the code below / Используйте код выше.
aternos.atconn.REQUA = ''
А откуда взять yourcokies?)
А откуда взять yourcokies?)
Я имею ввиду как получить эту строку?)
Говорю ж, из браузера.
В случае с Google Chrome:
WARNING:retry.api:'AternosConnect' object has no attribute 'cookies', retrying in 0 seconds...```
from python_aternos import Client, atconnect aternos = Client(atconnect.AternosConnect())
aternos.atconn.REQUA = ''
aternos.atconn.cookies.set('ATERNOS_SESSION', yourcookies) s = aternos.list_servers() print(s)
@DarkCat09 I'm still confused as how to use this method for other functions. For example, how would I use this with the Client.from_credentials() method?
@ZeynX92, ой, извините. Вот:
from python_aternos import Client, atconnect
aternos = Client(atconnect.AternosConnect())
# empty User-Agent
aternos.atconn.REQUA = ''
aternos.atconn.session.cookies.set('ATERNOS_SESSION', yourcookies)
s = aternos.list_servers()
print(s)
@flancast90, logging in with session can be performed with Client.from_session
(but not from_credentials).
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
DEBUG:root:Requesting(GET)https://aternos.org/servers/
DEBUG:root:headers={'Host': 'aternos.org', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36 OPR/85.0.4341.47', 'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="100", "Opera";v="86"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1'}
DEBUG:root:params={}
DEBUG:root:data={}
DEBUG:root:req-cookies={'ATERNOS_SESSION': '<мои cokies>'}
DEBUG:root:session-cookies=<RequestsCookieJar[]>
DEBUG:urllib3.connectionpool:Resetting dropped connection: aternos.org
DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 403 None
INFO:root:Retrying to bypass Cloudflare
@retry()
def get_server():
yourcookies = <мое значение cokies>
aternos = Client(atconnect.AternosConnect())
# empty User-Agent
aternos.atconn.REQUA = ''
aternos.atconn.session.cookies.set('ATERNOS_SESSION', yourcookies)
s = aternos.list_servers()
print(s)
logging in with session can be performed with Client.from_session (but not from_credentials).
How do I have a session if I can't login with from_credentials? The entire premise of my project relies on automating the login on my server to get the necessary data.
Is there a way to use the blank REQUA with the from_credentials method? I don't necessarily need to login with session.
@DarkCat09 @ZeynX92 I solved it! After about 5 hours of trial+error (I even wrote my own fork of this trying stuff!), I simply added:
atconnect.REQHEADERS = {}
before my from_credentials() call. After that, everything worked perfectly! I want to thank @DarkCat09 for all their help in solving this for my latest project, an auto-website generator/API utilising Aternos. My demo is hosted at https://minecraft.finnsoftware.net if you want to check it out!
EDIT: This solution worked until I restarted my server a third time. Based on what I can see through this behavior, I am wondering if Cloudflare has a ban system based on requests, headers, and timing which could be blocking the API. I will continue experimenting to find a fully-working solution, but I'm believing more and more that the issue is not with this library, but with Cloudscraper.
python_aternos.aterrors.CredentialsError: Unable to parse TOKEN from the page - For some reason this error appears when running the code on Heroku, does anyone have a solution to this problem?
python_aternos.aterrors.CredentialsError: Unable to parse TOKEN from the page - Эта ошибка почему то появляется при запуске кода на хероку, есть ли у кого то решение данной проблемы?
Using selenium with the custom driver instead if cloudscraper will probably solve the problem. It is planned in v1.1.0
.
This error appears due to Cloudflare protection that knows all Replit/Heroku/etc. IPs and blocks them.
Должно решить проблему использование селениума с пользовательским драйвером вместо cloudscraper-а. Запланировано на версию v1.1.0
.
Ошибка появляется из-за системы защиты Cloudflare, которая, похоже, знает все айпишники Replit/Heroku/т.п. и блокирует их.
Using selenium with the custom driver instead if cloudscraper will probably solve the problem. It is planned in
v1.1.0
.
This error appears due to Cloudflare protection that knows all Replit/Heroku/etc. IPs and blocks them.
Должно решить проблему использование селениума с пользовательским драйвером вместо cloudscraper-а. Запланировано на версию
v1.1.0
.
Ошибка появляется из-за системы защиты Cloudflare, которая, похоже, знает все айпишники Replit/Heroku/т.п. и блокирует их.
Thank you for your prompt response. Do not tell me when version 1.1.0 will be released?
Благодарю за ваш быстрый ответ. Не подскажите когда выйдет версия 1.1.0?
Using selenium with the custom driver instead if cloudscraper will probably solve the problem. It is planned in
v1.1.0
. This error appears due to Cloudflare protection that knows all Replit/Heroku/etc. IPs and blocks them.Должно решить проблему использование селениума с пользовательским драйвером вместо cloudscraper-а. Запланировано на версию
v1.1.0
. Ошибка появляется из-за системы защиты Cloudflare, которая, похоже, знает все айпишники Replit/Heroku/т.п. и блокирует их.
Good idea to use selenium. I actually started transferring it over when mine started to stop working. Here's some helpful libs for it: https://pypi.org/project/selenium-stealth/.
Hello everyone! I have a problem, my code was broken yesterday. I have written code that got server and then users can start()/stop() server by using discord bot, but now I have an errors:
But my password and username is valid! I don`t know what to do with this... Can you help me, please?
Thanks in advance, I will appreciate any help : )