dear OpenSuse-Experts.
finally i am happy that python seems to run well on my opensuse-42.3 box.
**what happened: **I’m trying to login to a Wordpress based website using python’s request module and beautifulsoup4.
It seems like the code fails to sucessfully login. Also, there is no csrf token on the website. How do I sucessfully login to the website?
import requests
import bs4 as bs
with requests.session() as c:
link="https://gpldl.com/sign-in/" #link of the webpage to be logged in
initial=c.get(link) #passing the get request
login_data={"log":"*****","pwd":"******"} #the login data from any account on the site. Stars must be replaced with username and password
page_login=c.post(link, data=login_data) #posting the login data into the link
print(page_login) #checking status of requested page
page=c.get("https://gpldl.com/my-gpldl-account/") #requesting source code of logged in page
good_data = bs.BeautifulSoup(page.content, "lxml") #parsing it with BS4
print(good_data.title) #printing this gives the title that is got from the page when accessed from an logged-out account
i got back:
martin@linux-3645:~/dev/python> python w1.py
Traceback (most recent call last):
File "w1.py", line 1, in <module>
import requests
ImportError: No module named requests
well: Requests is not a built in module (does not come with the default python installation), so you will have to install it:
OSX/Linux
i used this command:
Use $ sudo pip install requests
if we have pip installed
Alternatively we can also use
sudo easy_install -U requests
if we have easy_install installed.
martin@linux-3645:~/dev/python> sudo pip install requests
Requirement already satisfied: requests in /usr/lib/python3.4/site-packages
martin@linux-3645:~/dev/python>
btw - see this …:
martin@linux-3645:~/dev/python> sudo pip install requests
Requirement already satisfied: requests in /usr/lib/python3.4/site-packages
martin@linux-3645:~/dev/python>
so what can i do now? -
greetings dilbertone