Home Afer logging in with requests module how can I start the actual page?
Reply: 0

Afer logging in with requests module how can I start the actual page?

P. Duarte
1#
P. Duarte Published in 2018-02-12 13:32:12Z

This question already has an answer here:

  • Make a POST request while redirecting in flask 1 answer
  • How can a unique Rserve connection be stored per session? 1 answer

I have successfully logged in to a webpage:

from flask import Flask, render_template, redirect, make_response
import requests
from bs4 import BeautifulSoup

payload = {'username':'user','password':'pass'}
url='http://www.website.com/login/index.php'

session_requests = requests.session()
r = session_requests.post(url, data=payload)
ck = session_requests.cookies.get_dict()

Now I wanted to start the actual page already logged in... I have tried to set cookies for that domain but now I know it is not possible...

@app.route('/file/<name>')
def download_pg(name):
    files = data()
    link = 0
    for i in files.values():
        for k,v in i.items():
            if k == name.replace("%20", " "):
                link = v
                break

    link = download(link)

    if not link:
        return '<p>Error</p>'

    resp = make_response(redirect(link, 301))
    for k,v in ck.items():
        resp.set_cookie(k,v, domain='http://www.website.com/')
        print(v)
    return resp

I am not sticking with flask, as long as I could deploy it online and start the actual page logged in, it is not possible to place the username and password at the url as GET request, as it is POST... So, how can I make it work?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297858 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO