Reputation: 385
import requests
dados = {"action": "polls",
"view":"process",
"poll_id":"2",
"poll_2":"6",
"poll_2_nonce":"e29cc82a53"}
url = "http://soulegal.byethost7.com/wp/wp-admin/admin-ajax.php"
requests.post(url, data=dados)
The site URL is : http://soulegal.byethost7.com/wp/2016/07/28/pesquisa-eu-sou-legal
The wordpress plugin is WP-Polls.
The site is mine (I’m not testing in third part page ) Still it does not work. I wonder what ‘s going on? I can vote manually but not with the code !
Upvotes: 1
Views: 1536
Reputation: 28845
So you need to do a few things:
You need to use a requests.Session
instance so it can track cookies for you, including the cookie that Wordpress uses to allow you to vote from your poll page (which you have to make a get request to first).
You need to get the nonce value dynamically
To vote repeatedly, you need to get rid of the voted cookie after submission.
Upvotes: 2
Reputation: 6327
Wordpress creates an IP/PC/Mac address and sever side keys (similiar to the PHP session id) which is used for loading. As well you might want to check what cookies are going back and forth between your browser and the voting poll page.
Upvotes: 1