Jump to content

Logging in to admin panel with phython request


Somepub

Recommended Posts

Hello! I would like to know how can I use python or wget script to loggin to admin panel.

 

My problem states on formdata, and I'm not sure how prestashop admin panel login works.

 

I'm using python script like this:

import requests
url = 'http://www.example.ee/admin/index.php?controller=AdminLogin&token=1a02dc4d606bca6c26e95ddea92d3d15'
payload = {'email': 'example',
          'passwd': 'example'}

with requests.Session() as s:
    p = s.post(url, data=payload)
    # print the html returned or something more intelligent to see if it's a successful login page.
    print p.text

    # An authorised request.
    r = s.get('A protected web page url')
    print r.text

But I  get an error:

Traceback (most recent call last):
  File "downlaods.py", line 12, in <module>
    r = s.get('A protected web page url')
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 454, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 388, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 293, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 353, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'A protected web page url': No schema supplied. Perhaps you meant http://A protected web page url?

Same for wget, Im using cookies to login, but I get an error:

Removing www.example.ee/admin/index.php?controller=AdminPdf, since it should be rejected

Is it even possible to use script to login to admin panel?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...