Python Forum

Full Version: Info web login
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello everybody.
Sorry for my english Cool Cool
I'm new and I'm a beginner

I have to check the articles on this website
http://dls.delonghigroup.com/index.php?lang=it

The site requires access with user and password
I tried with various scripts found on the web but I can not log in

Can someone help me?
Thank you
it requires a password. Contact the company here: https://www.delonghigroup.com/en/investo...s/contacts
for further details
I already have access data. I would like to create a script that allows me to login with Python
show us what you've tried
I thank you, I tried to do this
Unfortunately I can not show you the user and password, they are information that I can not disclose

The result is the html print of the login page.
It does not print the HTML of the article page
Code

import requests 

#here I send the data for the login 
r = requests.get('http://dls.delonghigroup.com/index.php?lang=it', auth=('?????', '?????')) 
print(r.status_code) # return code 200 

#here after logging in I insert a link to an article
articolo = requests.get('http://dls.delonghigroup.com/index.php?option=com_ecart&view=product&id=190353&lang=it') 

#print html page.  
print(articolo.content) 
you need to fix the structure of your code, and replace r with meaningful name:
import requests 
 
#here I send the data for the login 
response = requests.get('http://dls.delonghigroup.com/index.php?lang=it', auth=('?????', '?????'))
if response.status_code == 200:
    #here after logging in I insert a link to an article
    articolo = requests.get('http://dls.delonghigroup.com/index.php?option=com_ecart&view=product&id=190353&lang=it') 
    if articolo.status_code == 200:
        #print html page.  
        print(articolo.content)
    else:
        print('requests failed with code {}'.format(articolo.status_code))
else:
    print('requests failed with code {}'.format(response.status_code))
This may not fix your code, but it's still necessary (it worked when I tried it)
Ok I made this change
The problem is not solved yet.
They advised me to insert a request.session statement.
This is to keep the session open after sending the user and password.
Do you know how to use this function?

Thanks for your help
(Nov-22-2018, 02:13 PM)Larz60+ Wrote: [ -> ]see: http://docs.python-requests.org/en/maste...on-objects

ok Thanks
This is the form to which I have to send the user and password.
Which path should I follow to try to send data as a first approach


<jdoc:include type="modules" name="login" style="none" />

<form name="loginform" class="login-form clearfix"

action="http://dls.delonghigroup.com/index.php?lang=it"
method="post" id="login-form">
<input class="form-control" type="text" name="username" id="user_login" value="" size="20" placeholder="Nome utente" />
<input class="form-control" type="password" name="password" id="user_pass" value="" size="20" placeholder="Password" />
<input type="submit" name="" value="Accedi" />
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.login" />
<input type="hidden" name="return" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" />
<input type="hidden" name="2b3f87ea71dea4a2e0846c366c7c6097" value="1" /> </form>
Pages: 1 2