dear community,
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?
i got back:
OSX/Linux
i used this command:
Alternatively we can also use
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 requestswell: Requests is not a built in module (does not come with the default python installation), so we will have to install it:
OSX/Linux
i used this command:
Use $ sudo pip install requestssince i have pip installed
Alternatively we can also use
sudo easy_install -U requestsif 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>finally see also
File "w1.py", line 1, in <module> import requests ImportError: No module named requests 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?
Wordpress - super toolkits a. http://wpgear.org/ :: und b. https://github.com/miziomon/awesome-wordpress :: Awesome WordPress: A curated list of amazingly awesome WordPress resources and awesome python things https://github.com/vinta/awesome-python