Возникли проблемы с входом на конкретный сайт, запросом логина и пароля - PullRequest
0 голосов
/ 23 октября 2019

Я пытаюсь войти на этом веб-сайте

Я обнаружил, что при входе в систему вручную через браузер появляется следующее сообщение:

curl 'https://1xbfm.world/user/auth' -H $'cookie: lng=en; flaglng=en; is_rtl=1; tzo=3; promo_points=1; auid=U5PJzl2wHWF9qGzlAxFfAg==; typeBetNames=full; bonus_choice=0; blocks=1%2C1%2C1%2C1%2C1%2C1%2C1%2C1; completed_user_settings=true; _ym_uid=1571822956801134252; _ym_d=1571822956; _ga=GA1.2.1051603586.1571822956; _gid=GA1.2.47595177.1571822956; _ym_isad=1; che_g=1c390d42-1942-6e33-0a57-4a6099cdbfce; che_n=1; pushfree_status=canceled; coefview=0; indicator=1; act=20191023; dnb=1; SESSION=78c2f4774b8fefac1ab74f0dae7a0eed; asia_view=0; compact_vid_off=0; lite_version=0; disable_line_express=0; disable_live_express=0; colorChange=0; autoSummSel_off=0; only_betting=0; show_number_game=0; font_size=f-s_normal; new_view_score=false; new_view_custom_group_765=false; extended_scores_dashboard_off=0; game_cols_count=2; show_popup_lucky_wheel=0; hide_slider_top_games=0; coupon_logo=0; statistic_in_modal=0; when_change_coef=1; is_goldenbet_enabled=0; side_video_setting=0; videos=%5B%7B%22video_id%22%3A%22xgame7_26127%22%2C%22gameId%22%3A211581419%2C%22sportId%22%3A103%2C%22countryId%22%3A225%2C%22champId%22%3A1252965%2C%22title%22%3A%221544.%20Mortal%20Kombat%20X.%20D\'Vorah%20-%20Sub-Zero%20%22%2C%22position%22%3A%22left%22%2C%22prev_position%22%3A%22left%22%2C%22iframePlayer%22%3Afalse%7D%5D; activeid=15606495; _glhf=1571856537; _ym_visorc_22934032=b; ggru=181; _gat=1; _grant_1571856537=md14op104' -H 'origin: https://1xbfm.world' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' -H 'content-type: application/json;charset=UTF-8' -H 'accept: application/json, text/plain, */*' -H 'referer: https://1xbfm.world/' -H 'authority: 1xbfm.world' -H 'x-requested-with: XMLHttpRequest' --data-binary '{"uLogin":"my_login","uPassword":"my_password","save":false}' --compressed

Я использую онлайн-инструмент , чтобы преобразовать его в код запросов Python. Вот полный код, который у меня есть:

from requests_html import HTMLSession

session = HTMLSession()

def login(session):
    headers = {
    '$cookie': 'lng=en; flaglng=en; is_rtl=1; tzo=3; promo_points=1; auid=U5PJzl2wHWF9qGzlAxFfAg==; typeBetNames=full; bonus_choice=0; blocks=1%2C1%2C1%2C1%2C1%2C1%2C1%2C1; completed_user_settings=true; _ym_uid=1571822956801134252; _ym_d=1571822956; _ga=GA1.2.1051603586.1571822956; _gid=GA1.2.47595177.1571822956; _ym_isad=1; che_g=1c390d42-1942-6e33-0a57-4a6099cdbfce; che_n=1; pushfree_status=canceled; coefview=0; indicator=1; act=20191023; dnb=1; SESSION=78c2f4774b8fefac1ab74f0dae7a0eed; asia_view=0; compact_vid_off=0; lite_version=0; disable_line_express=0; disable_live_express=0; colorChange=0; autoSummSel_off=0; only_betting=0; show_number_game=0; font_size=f-s_normal; new_view_score=false; new_view_custom_group_765=false; extended_scores_dashboard_off=0; game_cols_count=2; show_popup_lucky_wheel=0; hide_slider_top_games=0; coupon_logo=0; statistic_in_modal=0; when_change_coef=1; is_goldenbet_enabled=0; side_video_setting=0; videos=%5B%7B%22video_id%22%3A%22xgame7_26127%22%2C%22gameId%22%3A211581419%2C%22sportId%22%3A103%2C%22countryId%22%3A225%2C%22champId%22%3A1252965%2C%22title%22%3A%221544.%20Mortal%20Kombat%20X.%20D\'Vorah%20-%20Sub-Zero%20%22%2C%22position%22%3A%22left%22%2C%22prev_position%22%3A%22left%22%2C%22iframePlayer%22%3Afalse%7D%5D; activeid=15606495; _glhf=1571856537; _ym_visorc_22934032=b; ggru=181; _gat=1; _grant_1571856537=md14op104',
'origin': 'https://1xbfm.world',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
'content-type': 'application/json;charset=UTF-8',
'accept': 'application/json, text/plain, */*',
'referer': 'https://1xbfm.world/',
'authority': '1xbfm.world',
'x-requested-with': 'XMLHttpRequest',
}


data = { "uLogin":"my_login", "uPassword":"my_password", "save":False }
response = session.post('https://1xbfm.world/user/auth', headers=headers, data=data)
print(response.__dict__)
return session

session = HTMLSession()
session = login(session)

Вывод с ошибкой:

{'_content': b'{"type":1,"message":"To log in to your account please enter your username (ID) and password.","success":false}', '_content_consumed': True, '_next': None, 'status_code': 200, 'headers': {'Server': 'nginx', 'Date': 'Wed, 23 Oct 2019 14:28:30 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '110', 'Connection': 'keep-alive', 'Set-Cookie': 'SESSION=5337a73da11b840834eb578fcde1415e; path=/; secure; HttpOnly, ua=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/, lng=en; expires=Fri, 22-Nov-2019 14:28:30 GMT; Max-Age=2592000; path=/, flaglng=en; expires=Fri, 22-Nov-2019 14:28:30 GMT; Max-Age=2592000; path=/, disallow_sport=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/, is_rtl=1; expires=Thu, 22-Oct-2020 14:28:30 GMT; Max-Age=31536000; path=/, auid=U5PJzl2wY46tdkYYA3IAAg==; expires=Thu, 22-Oct-20 14:28:30 GMT; path=/', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Pragma': 'no-cache', 'Strict-Transport-Security': 'max-age=15768000'}, 'raw': <urllib3.response.HTTPResponse object at 0x10cd00c90>, 'url': 'https://1xbfm.world/user/auth', 'encoding': 'utf-8', 'history': [], 'reason': 'OK', 'cookies': <RequestsCookieJar[Cookie(version=0, name='SESSION', value='5337a73da11b840834eb578fcde1415e', port=None, port_specified=False, domain='1xbfm.world', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=True, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False), Cookie(version=0, name='auid', value='U5PJzl2wY46tdkYYA3IAAg==', port=None, port_specified=False, domain='1xbfm.world', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=1603376910, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False), Cookie(version=0, name='flaglng', value='en', port=None, port_specified=False, domain='1xbfm.world', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=1574432910, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False), Cookie(version=0, name='is_rtl', value='1', port=None, port_specified=False, domain='1xbfm.world', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=1603376910, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False), Cookie(version=0, name='lng', value='en', port=None, port_specified=False, domain='1xbfm.world', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=1574432910, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False)]>, 'elapsed': datetime.timedelta(microseconds=247320), 'request': <PreparedRequest [POST]>, '_html': None, 'session': <requests_html.HTMLSession object at 0x10f534f50>, 'connection': <requests.adapters.HTTPAdapter object at 0x10f543110>}

Я не понимаю, почему сервер не видит мой логин и пароль и просит ввести его, как я могу это исправить?

...