Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Post method

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?

like image 330
Walid Saad Avatar asked Jan 23 '16 14:01

Walid Saad


1 Answers

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)
like image 97
JRodDynamite Avatar answered Sep 18 '22 01:09

JRodDynamite