Skip to main content

Wrapper around selenium and requests to make it easier to use proxies.

Project description

t-proxy-toolkit

This is a wrapper around rpaframework selenium driver to enable a proxy using NordLayer. You can use this too to start a request session using NordVPN

How do I get set up?

  • To install it just run

    `pip install t-proxy-toolkit`
    

How to integrate this in my code

For browser usage

Instead of creating a new selenium object from rpaframework, call this library with the method chrome or firefox and optional, the init preferences or options to the browser in a dict.

By default, the browser will assign a custom UserAgent using the fake-useragent package and this settings and the correct ua if the browser open is chrome or firefox:

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

# For chrome
user_agent.chrome

# For firefox
user_agent.firefox

:bangbang: :warning: It's a known issue that you can't use headless when you're trying to install an extension :warning: :bangbang:

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

browser_proxy = BrowserProxy()

# get this from bitwarden
user = "" # user
password = "" # pwd
organization = "thoughtful" # should be thoughtful always
network = "" # name of the network to use


# call the browser you want to use, set the variable to Selenium class to enable the autocomplete

firefox: Selenium = browser_proxy.firefox(user, password, network, organization)
chrome: Selenium = browser_proxy.chrome(user, password, network, organization)

Setup preferences or options

For firefox you can send parameters to the browser object with a dictionary. The full list of preferences in the following links:

prefs: dict = {
            "download.default_directory": "some/path/to/output",
      }

firefox: Selenium = browser_proxy.firefox(user, password, network, organization, prefs)

For chrome you can send parameters to the browser object with the options object from selenium chrome. The full list of preferences in the following links:

from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--no-sandbox")

chrome: Selenium = browser_proxy.chrome(user, password, network, organization, options)

For requests usage

This will use the Oxylabs servers available and will start a requests session with the https proxy enabled.

If port is 8000, it will return a different IP on every request.

If port is 8001 to 8010, it will use a fixed IP all the time.

IPs can be changed anytime from Oxylabs dashboard.

from t_proxy import RequestsProxy
from requests import Session

# get this from bitwarden
creds = {
      "login": "", # user
      "password": "", # pwd
      "port": ""
}
requests_proxy = RequestsProxy()
session: Session = session.session(creds)

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

Current bots using this tool

Bot Code Firefox Chrome Requests
DMA2 :white_check_mark: :x: :x:
SD2 :x: :x: :white_check_mark:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t_proxy_toolkit-0.1.4.tar.gz (3.5 MB view details)

Uploaded Source

File details

Details for the file t_proxy_toolkit-0.1.4.tar.gz.

File metadata

  • Download URL: t_proxy_toolkit-0.1.4.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for t_proxy_toolkit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 11a63f50df9a3e9c4aa585ae275b5ef6e34e00c59e4a9c63526916e53b03afe8
MD5 46b538fb893820929041569fb6441703
BLAKE2b-256 6bacc456307b955005f80844d2e1af1d686c7e1f8acbd12ad1e2562ef4510ea3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page