t-proxy-toolkit


Namet-proxy-toolkit JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://www.thoughtful.ai/
SummaryWrapper around selenium and requests to make it easier to use proxies.
upload_time2024-12-12 17:36:19
maintainerNone
docs_urlNone
authorThoughtful
requires_python>=3.9
licenseNone
keywords t-proxy-toolkit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # t-proxy-toolkit #
A wrapper around rpaframework selenium driver to enable proxy usage with Oxylabs. You can also use this tool to start a request session using Oxylabs.

# Installation #

Install using pip:

```pip install t-proxy-toolkit```

# Usage #

## Browser Usage ##

Instead of creating a selenium object directly from rpaframework, use this library's `chrome` or `firefox` methods. You can optionally provide initialization preferences or options for the browser as a dictionary.

By default, the browser will be assigned a custom UserAgent using the fake-useragent package with these settings:

```python
from fake_useragent import UserAgent

user_agent = UserAgent(os="windows", min_percentage=1.3)

# For chrome
user_agent.chrome

# For firefox
user_agent.firefox
```

:warning: **Note**: Headless mode cannot be used when installing browser extensions :warning:

Basic usage example:

```python
from t_proxy import BrowserProxy
from RPA.Browser.Selenium import Selenium

browser_proxy = BrowserProxy()

# Proxy credentials
user = "your_username"
password = "your_password" 
host = "proxy.host.com"
port = "12345"

# Initialize browsers - type hints added for better IDE support
firefox: Selenium = browser_proxy.firefox(user, password, host, port)
chrome: Selenium = browser_proxy.chrome(user, password, host, port)
```

You can create a new user for metrics and usage tracking in the Oxylabs dashboard.

## Browser Configuration ##

### Firefox Preferences ###
You can configure Firefox by passing a preferences dictionary. Reference the following Mozilla documentation for available preferences:

* [firefox.js](https://searchfox.org/mozilla-release/source/browser/app/profile/firefox.js)
* [all.js](https://searchfox.org/mozilla-release/source/modules/libpref/init/all.js)
* [StaticPrefList.yaml](https://searchfox.org/mozilla-release/source/modules/libpref/init/StaticPrefList.yaml)

Example:

```python
prefs = {
    "download.default_directory": "/path/to/downloads",
    "browser.download.folderList": 2
}

firefox: Selenium = browser_proxy.firefox(user, password, host, port, prefs)
```

### Chrome Options ###
For Chrome, you can pass selenium ChromeOptions. Reference these resources for available options:

* [Chromium command line switches](https://peter.sh/experiments/chromium-command-line-switches/)
* [chrome_switches.cc](https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc)
* [Source code search](https://source.chromium.org/search?q=file:switches.cc&ss=chromium%2Fchromium%2Fsrc)

Example:

```python
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")

chrome: Selenium = browser_proxy.chrome(user, password, host, port, options)
```

## Requests Usage ##
Use Oxylabs proxy servers with Python requests. The proxy behavior depends on the port:

- Port 8000: Returns a different IP for each request
- Ports 8001-8010: Uses a fixed IP for all requests

IPs can be managed through the Oxylabs dashboard.

Example:

```python
from t_proxy import RequestsProxy
from requests import Session

# Proxy configuration
creds = {
    "login": "your_username",
    "password": "your_password",
    "port": "8000"  # or 8001-8010 for fixed IP
}

requests_proxy = RequestsProxy()
session: Session = requests_proxy.session(creds)

# Make requests
response = session.get("https://api.ipify.org?format=json")
print(response.json())
```

## Projects Using This Tool ##

Bot Code | Firefox | Chrome | Requests |
--- | --- | --- | --- |
DMA2 | ✅ | ❌ | ❌ |
SD2 | ❌ | ❌ | ✅ |

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.thoughtful.ai/",
    "name": "t-proxy-toolkit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "t-proxy-toolkit",
    "author": "Thoughtful",
    "author_email": "support@thoughtful.ai",
    "download_url": "https://files.pythonhosted.org/packages/6b/08/121e83b7ea0075693a3ceb24d93cdf7d555f638c12e4684ad3327ef7f5ef/t_proxy_toolkit-0.2.0.tar.gz",
    "platform": null,
    "description": "# t-proxy-toolkit #\nA wrapper around rpaframework selenium driver to enable proxy usage with Oxylabs. You can also use this tool to start a request session using Oxylabs.\n\n# Installation #\n\nInstall using pip:\n\n```pip install t-proxy-toolkit```\n\n# Usage #\n\n## Browser Usage ##\n\nInstead of creating a selenium object directly from rpaframework, use this library's `chrome` or `firefox` methods. You can optionally provide initialization preferences or options for the browser as a dictionary.\n\nBy default, the browser will be assigned a custom UserAgent using the fake-useragent package with these settings:\n\n```python\nfrom fake_useragent import UserAgent\n\nuser_agent = UserAgent(os=\"windows\", min_percentage=1.3)\n\n# For chrome\nuser_agent.chrome\n\n# For firefox\nuser_agent.firefox\n```\n\n:warning: **Note**: Headless mode cannot be used when installing browser extensions :warning:\n\nBasic usage example:\n\n```python\nfrom t_proxy import BrowserProxy\nfrom RPA.Browser.Selenium import Selenium\n\nbrowser_proxy = BrowserProxy()\n\n# Proxy credentials\nuser = \"your_username\"\npassword = \"your_password\" \nhost = \"proxy.host.com\"\nport = \"12345\"\n\n# Initialize browsers - type hints added for better IDE support\nfirefox: Selenium = browser_proxy.firefox(user, password, host, port)\nchrome: Selenium = browser_proxy.chrome(user, password, host, port)\n```\n\nYou can create a new user for metrics and usage tracking in the Oxylabs dashboard.\n\n## Browser Configuration ##\n\n### Firefox Preferences ###\nYou can configure Firefox by passing a preferences dictionary. Reference the following Mozilla documentation for available preferences:\n\n* [firefox.js](https://searchfox.org/mozilla-release/source/browser/app/profile/firefox.js)\n* [all.js](https://searchfox.org/mozilla-release/source/modules/libpref/init/all.js)\n* [StaticPrefList.yaml](https://searchfox.org/mozilla-release/source/modules/libpref/init/StaticPrefList.yaml)\n\nExample:\n\n```python\nprefs = {\n    \"download.default_directory\": \"/path/to/downloads\",\n    \"browser.download.folderList\": 2\n}\n\nfirefox: Selenium = browser_proxy.firefox(user, password, host, port, prefs)\n```\n\n### Chrome Options ###\nFor Chrome, you can pass selenium ChromeOptions. Reference these resources for available options:\n\n* [Chromium command line switches](https://peter.sh/experiments/chromium-command-line-switches/)\n* [chrome_switches.cc](https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc)\n* [Source code search](https://source.chromium.org/search?q=file:switches.cc&ss=chromium%2Fchromium%2Fsrc)\n\nExample:\n\n```python\nfrom selenium.webdriver.chrome.options import Options\n\noptions = Options()\noptions.add_argument(\"--no-sandbox\")\noptions.add_argument(\"--disable-dev-shm-usage\")\n\nchrome: Selenium = browser_proxy.chrome(user, password, host, port, options)\n```\n\n## Requests Usage ##\nUse Oxylabs proxy servers with Python requests. The proxy behavior depends on the port:\n\n- Port 8000: Returns a different IP for each request\n- Ports 8001-8010: Uses a fixed IP for all requests\n\nIPs can be managed through the Oxylabs dashboard.\n\nExample:\n\n```python\nfrom t_proxy import RequestsProxy\nfrom requests import Session\n\n# Proxy configuration\ncreds = {\n    \"login\": \"your_username\",\n    \"password\": \"your_password\",\n    \"port\": \"8000\"  # or 8001-8010 for fixed IP\n}\n\nrequests_proxy = RequestsProxy()\nsession: Session = requests_proxy.session(creds)\n\n# Make requests\nresponse = session.get(\"https://api.ipify.org?format=json\")\nprint(response.json())\n```\n\n## Projects Using This Tool ##\n\nBot Code | Firefox | Chrome | Requests |\n--- | --- | --- | --- |\nDMA2 | \u2705 | \u274c | \u274c |\nSD2 | \u274c | \u274c | \u2705 |\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Wrapper around selenium and requests to make it easier to use proxies.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://www.thoughtful.ai/"
    },
    "split_keywords": [
        "t-proxy-toolkit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b08121e83b7ea0075693a3ceb24d93cdf7d555f638c12e4684ad3327ef7f5ef",
                "md5": "59f802b64438b16aa263b17e4b929c78",
                "sha256": "8cb15c1813a28fa7232dcc0a6d3d04dcae618e4a3987269a837bce60d6c57205"
            },
            "downloads": -1,
            "filename": "t_proxy_toolkit-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "59f802b64438b16aa263b17e4b929c78",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 552737,
            "upload_time": "2024-12-12T17:36:19",
            "upload_time_iso_8601": "2024-12-12T17:36:19.299992Z",
            "url": "https://files.pythonhosted.org/packages/6b/08/121e83b7ea0075693a3ceb24d93cdf7d555f638c12e4684ad3327ef7f5ef/t_proxy_toolkit-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 17:36:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "t-proxy-toolkit"
}
        
Elapsed time: 3.17548s