python3 - can't pass through autorization
Question: I need to build webcrawler for internal usage and I need to login into
administration area. I'm trying to use requests lib, tried this ways:

    
    
    import urllib.parse
    import requests
    
    base_url = "https://target.url"
    
    data = ({'login': 'login', 'pass': 'password'})
    
    params = urllib.parse.urlencode(data)
    
    r = requests.post(base_url, data=params)
    
    print(r.text)
    

and

    
    
    import requests
    
    base_url = "https://target.url"
    
    r = requests.post(base_url, auth=('login', 'password')
    
    print(r.text)
    

but in both cases r.text returns me login page content same as if I try to get
any other page after auth code:

    
    
    req = requests.get("https://target.url/smth")
    

What I lose sight of? I have ideas:

  1. chain of hidden redirections from <https://target.url> to real login page, so I send auth info to wrong url
  2. I don't send additional required info (like cookies e.g.)

Could you please comment? How can I gather required for login information?


Answer: In my case problem was in 'Referer' parameter in headers, which is required
but wasn't specified

