Info web login - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Info web login (/thread-14218.html) Pages:
1
2
|
Info web login - antonio04 - Nov-20-2018 Hello everybody. Sorry for my english 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 RE: Info web login - Larz60+ - Nov-20-2018 it requires a password. Contact the company here: https://www.delonghigroup.com/en/investor-relations/contacts for further details RE: Info web login - antonio04 - Nov-20-2018 I already have access data. I would like to create a script that allows me to login with Python RE: Info web login - Larz60+ - Nov-20-2018 show us what you've tried RE: Info web login - antonio04 - Nov-21-2018 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) RE: Info web login - Larz60+ - Nov-21-2018 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) RE: Info web login - antonio04 - Nov-22-2018 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 RE: Info web login - Larz60+ - Nov-22-2018 see: http://docs.python-requests.org/en/master/user/advanced/#session-objects RE: Info web login - antonio04 - Nov-22-2018 (Nov-22-2018, 02:13 PM)Larz60+ Wrote: see: http://docs.python-requests.org/en/master/user/advanced/#session-objects ok Thanks RE: Info web login - antonio04 - Nov-23-2018 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> |