selenium-requests


Nameselenium-requests JSON
Version 2.0.4 PyPI version JSON
download
home_pagehttps://github.com/cryzed/Selenium-Requests
SummaryExtends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.
upload_time2024-02-29 17:16:48
maintainer
docs_urlNone
authorChris Braun
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Selenium Requests
=================
Extends Selenium WebDriver classes to include the
[request](http://docs.python-requests.org/en/latest/api/#requests.request) function from the
[Requests](http://python-requests.org/) library, while doing all the needed cookie and request headers handling.

Before the actual request is made, a local HTTP server is started that serves a single request made by the webdriver
instance to get the "standard" HTTP request headers sent by this webdriver; these are cached (only happens once during
its lifetime) and later used in conjunction with the Requests library to make the requests look identical to those that
would have been sent by the webdriver. Cookies held by the webdriver instance are added to the request headers and those
returned in a response automatically set for the webdriver instance.


Features
--------
 * Determines and sends the default HTTP headers (User-Agent etc.) for the chosen WebDriver
 * Manages cookies bidirectionally between requests and Selenium
 * Switches to already existing window handles or temporarily creates them to work with the webdriver's cookies when
   making a request
 * All operations preserve the original state of the WebDriver (active window handle and window handles)
 * Tested to work with Selenium (v4.1.0) using Mozilla Firefox (v97.0) and Chromium (v98.0.4758.80)


Usage
-----
```python
# Import any WebDriver class that you would usually import from
# selenium.webdriver from the seleniumrequests module
from seleniumrequests import Firefox

# Simple usage with built-in WebDrivers:
webdriver = Firefox()
response = webdriver.request('GET', 'https://www.google.com/')
print(response)


# More complex usage, using a WebDriver from another Selenium-related module:
from seleniumrequests.request import RequestsSessionMixin
from someothermodule import CustomWebDriver


class MyCustomWebDriver(RequestsSessionMixin, CustomWebDriver):
    pass


custom_webdriver = MyCustomWebDriver()
response = custom_webdriver.request('GET', 'https://www.google.com/')
print(response)
```


Installation
------------
```pip install selenium-requests```


Remote WebDriver
----------------
When using `webdriver.Remote` it is very likely that the HTTP proxy server spawned by `selenium-requests` does not run
on the same machine. By default, the webdriver tries to access the proxy server under `127.0.0.1`. This can be changed
by passing the `proxy_host=` argument with the correct IP or hostname to the webdriver.

```python
driver = seleniumrequests.Remote(
    'http://192.168.101.1:4444/wd/hub',
    options=chrome_options,
    proxy_host='192.168.101.2'
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cryzed/Selenium-Requests",
    "name": "selenium-requests",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Chris Braun",
    "author_email": "cryzed@googlemail.com",
    "download_url": "https://files.pythonhosted.org/packages/de/5d/a8b846d23566d806035f8220945563c8cbd819635b5cdf50da8916ba6c49/selenium_requests-2.0.4.tar.gz",
    "platform": null,
    "description": "Selenium Requests\n=================\nExtends Selenium WebDriver classes to include the\n[request](http://docs.python-requests.org/en/latest/api/#requests.request) function from the\n[Requests](http://python-requests.org/) library, while doing all the needed cookie and request headers handling.\n\nBefore the actual request is made, a local HTTP server is started that serves a single request made by the webdriver\ninstance to get the \"standard\" HTTP request headers sent by this webdriver; these are cached (only happens once during\nits lifetime) and later used in conjunction with the Requests library to make the requests look identical to those that\nwould have been sent by the webdriver. Cookies held by the webdriver instance are added to the request headers and those\nreturned in a response automatically set for the webdriver instance.\n\n\nFeatures\n--------\n * Determines and sends the default HTTP headers (User-Agent etc.) for the chosen WebDriver\n * Manages cookies bidirectionally between requests and Selenium\n * Switches to already existing window handles or temporarily creates them to work with the webdriver's cookies when\n   making a request\n * All operations preserve the original state of the WebDriver (active window handle and window handles)\n * Tested to work with Selenium (v4.1.0) using Mozilla Firefox (v97.0) and Chromium (v98.0.4758.80)\n\n\nUsage\n-----\n```python\n# Import any WebDriver class that you would usually import from\n# selenium.webdriver from the seleniumrequests module\nfrom seleniumrequests import Firefox\n\n# Simple usage with built-in WebDrivers:\nwebdriver = Firefox()\nresponse = webdriver.request('GET', 'https://www.google.com/')\nprint(response)\n\n\n# More complex usage, using a WebDriver from another Selenium-related module:\nfrom seleniumrequests.request import RequestsSessionMixin\nfrom someothermodule import CustomWebDriver\n\n\nclass MyCustomWebDriver(RequestsSessionMixin, CustomWebDriver):\n    pass\n\n\ncustom_webdriver = MyCustomWebDriver()\nresponse = custom_webdriver.request('GET', 'https://www.google.com/')\nprint(response)\n```\n\n\nInstallation\n------------\n```pip install selenium-requests```\n\n\nRemote WebDriver\n----------------\nWhen using `webdriver.Remote` it is very likely that the HTTP proxy server spawned by `selenium-requests` does not run\non the same machine. By default, the webdriver tries to access the proxy server under `127.0.0.1`. This can be changed\nby passing the `proxy_host=` argument with the correct IP or hostname to the webdriver.\n\n```python\ndriver = seleniumrequests.Remote(\n    'http://192.168.101.1:4444/wd/hub',\n    options=chrome_options,\n    proxy_host='192.168.101.2'\n)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.",
    "version": "2.0.4",
    "project_urls": {
        "Homepage": "https://github.com/cryzed/Selenium-Requests",
        "Repository": "https://github.com/cryzed/Selenium-Requests"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b2c9c3b3fbe42f3e1643ec24e31f76bd52642cc3a3e43423d62be7ea61d4342",
                "md5": "0d13ff6ad40ff70c6a7cdd95eb7b2148",
                "sha256": "ab6e4ebee0fdd7185dcf289c90227cec4bd1056d097cf690c78105fbcb9c29d3"
            },
            "downloads": -1,
            "filename": "selenium_requests-2.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d13ff6ad40ff70c6a7cdd95eb7b2148",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 6825,
            "upload_time": "2024-02-29T17:16:43",
            "upload_time_iso_8601": "2024-02-29T17:16:43.482909Z",
            "url": "https://files.pythonhosted.org/packages/7b/2c/9c3b3fbe42f3e1643ec24e31f76bd52642cc3a3e43423d62be7ea61d4342/selenium_requests-2.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de5da8b846d23566d806035f8220945563c8cbd819635b5cdf50da8916ba6c49",
                "md5": "479c2e1efd9226755a4431dc3eddf64c",
                "sha256": "8c5366561a366a6eeb05caa8c9141a18b4dbb672c90404e240d00c5301409251"
            },
            "downloads": -1,
            "filename": "selenium_requests-2.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "479c2e1efd9226755a4431dc3eddf64c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 6074,
            "upload_time": "2024-02-29T17:16:48",
            "upload_time_iso_8601": "2024-02-29T17:16:48.205066Z",
            "url": "https://files.pythonhosted.org/packages/de/5d/a8b846d23566d806035f8220945563c8cbd819635b5cdf50da8916ba6c49/selenium_requests-2.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-29 17:16:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cryzed",
    "github_project": "Selenium-Requests",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "selenium-requests"
}
        
Elapsed time: 0.21772s