Reputation: 1001
I'm trying to find a way to get the response of a post method executed through headless browser.
session = requests.Session()
session.get(<url here)
print session.cookies
r = session.post(url).content
print r
The problem is that the response r is full of javascript and I can't use Selenium to execute it because it doesn't support the POST method (as far as I know). Any ideas?
Upvotes: 8
Views: 43887
Reputation: 12613
You can try using selenium-requests
:
Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.
Example:
from seleniumrequests import Firefox
webdriver = Firefox()
response = webdriver.request('POST', 'url here', data={"param1": "value1"})
print(response)
Upvotes: 16