S
S
Sergey2018-09-09 00:03:22
Python
Sergey, 2018-09-09 00:03:22

Why doesn't it go further with requests?

I pass it turns out to the intermediate page. How to make the page load further?
Knocks out this:
Welcome back, userid . Logging you in...

<script language="Javascript">location.href='/adminpanel/index.php';</script>

The code:
import requests

payload = {
    'ID' : 'userid',
    'Password' : 't43dwd'
}

with requests.Session() as s:
    p = s.post('https://site.ru/adminpanel/index.php', data=payload)
    print(p.text)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2018-09-09
@alekskondr

requests is not suitable, you need to use selenium.
With requests, the page does not load to the end

A
Alex F, 2018-09-10
@delvin-fil

Try like this:

#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import requests
from requests.auth import HTTPDigestAuth
headers = {
  'User-agent': 'Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0',
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-language': 'ru,en-US;q=0.7,en;q=0.3',
  'Accept-encoding': 'gzip, deflate',
  'Dnt': '1',
  'Connection': 'keep-alive',
  'Cache-Control' : "max-age=0",
  'Cookie' : "_gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1",
  'Upgrade-insecure-requests': '1',
  'X-DNS-Prefetch-Control': 'on',
  'Cf-Visitor': '{"scheme":"https"}',
  'X-Forwarded-Proto': 'https'
}
login = 'userid'
password = 't43dwd'
url = 'https://site.ru/adminpanel/index.php'
startp = requests.get(url, auth=HTTPDigestAuth(login, password), headers=headers).text
print (startp)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question