Skip to main content

A Python package for making HTTP requests with proxy support and fetching HTML content using requests or Selenium.

Project description

proxyrequest

proxyrequest is a Python package that allows you to make HTTP requests and retrieve HTML content using a proxy. It supports both standard HTTP requests and Selenium-based requests for more dynamic content fetching.

Features

  • Proxy Support: Easily integrate proxies into your HTTP requests.
  • HTML Content Retrieval: Fetch HTML content using requests or Selenium.
  • Selenium Integration: Use Selenium for dynamic pages when requests alone don't suffice.

Installation

You can install proxyrequest via pip:

pip install proxyrequest

# ================================================================

from proxyrequest import proxy_verifier
# Checks whether the given proxy is working by making a simple HTTP request to a test URL.

# Define your proxy settings (this is just an example, use a valid proxy IP and port)
proxy = {
    "http": "http://proxy_ip:port",
    "https": "https://proxy_ip:port"
}

proxy = {
    "http": "http://10.10.1.10:3128",
    "https": "https://10.10.1.10:1080"
}

# Call the function with the proxy
is_working = proxy_verifier(proxy)

# Print the result
if is_working:
    print("The proxy is working!")
else:
    print("The proxy is not working.")


# Define custom headers
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
    'Accept': 'application/json'
}

# Call the function with custom headers
is_working = proxy_verifier(proxy, headers=headers)

# Print the result
if is_working:
    print("The proxy is working!")
else:
    print("The proxy is not working.")


# Call the function with a custom timeout of 10 seconds
is_working = proxy_verifier(proxy, timeout=10)

# Print the result
if is_working:
    print("The proxy is working!")
else:
    print("The proxy is not working.")


# Call the function with SSL verification disabled
is_working = proxy_verifier(proxy, verify=False)

# Print the result
if is_working:
    print("The proxy is working!")
else:
    print("The proxy is not working.")

# Without Proxy (Direct Request for Public IP)
proxy_verifier(proxy=None)


from proxyrequest import get_request

url = "https://example.com"
response = get_request(url, country="US", protocol="http", max_retries=5)

# Process the response
if response.status_code == 200:
    print("Request was successful!")
    print(response.content)


# Example to fetch and use proxies for multiple requests
from proxyrequest import fetch_proxy_ips, get_request

# Fetch proxies
proxies = fetch_proxy_ips(country="GB", protocol="https", limit=5)

# Example URL
url = "https://httpbin.org/ip"

for proxy in proxies:
    print(f"Using proxy: {proxy['proxy']}")
    response = get_request(url, country="GB", protocol="https")
    if response and response.status_code == 200:
        print(f"Successful response: {response.text}")
    else:
        print("Request failed")

# dynamic content fetching
from proxyrequest import get_chrome_request_driver

driver = get_chrome_request_driver(
    headless=True,
    proxy="http://127.0.0.1:8080",
    window_size="1366,768"
)

if driver:
    driver.get("https://httpbin.org/ip")
    print(driver.page_source)
    driver.quit()


# ------------------------------------
# Playwright Chrome Example
# ------------------------------------
from proxyrequest import launch_browser, get_api_response_data

# -------------------------------
# Launch Chrome with a persistent profile
# -------------------------------
profile_path = "./my_profile"
page, context = launch_browser(profile_path=profile_path, headless=False)

# Open a page
page.goto("https://example.com")
print("Opened page with persistent profile")
context.close()

# -------------------------------
# Launch Chrome without a profile
# -------------------------------
page, context = launch_browser(headless=False)
page.goto("https://example.com")
print("Opened page without profile")
context.close()

# -------------------------------
# Launch Chrome with custom headers
# -------------------------------
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
}
page, context = launch_browser(headers=headers, headless=False)
page.goto("https://example.com")
print("Opened page with custom headers")
context.close()

# -------------------------------
# Launch Chrome using a proxy
# -------------------------------
proxy = {
    "server": "http://myproxyserver.com:8080",  # Replace with your proxy server
    "username": "myusername",                   # Optional
    "password": "mypassword",                   # Optional
}
page, context = launch_browser(headless=False, proxy=proxy)
page.goto("https://httpbin.org/ip")  # Test IP through proxy
print(page.content())
context.close()

# -------------------------------
# Capture API Response
# -------------------------------
page, context = launch_browser(profile_path="./profile", headless=False)
api_data = get_api_response_data(page, api_end_point="https://example.com/api/data")
print("Captured API Data:", api_data)
context.close()

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

proxyrequest-0.0.18.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proxyrequest-0.0.18-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file proxyrequest-0.0.18.tar.gz.

File metadata

  • Download URL: proxyrequest-0.0.18.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for proxyrequest-0.0.18.tar.gz
Algorithm Hash digest
SHA256 7af9b7794ecd51f23256ddce5b388b3e5c121fc69f730acbae847f4c4cda8c25
MD5 fceb8e261e28dedef07bcf4fdde8265e
BLAKE2b-256 a23197fe62190d460e6a88e4f806144d9aaa3a4a8860f94c02eec53a89e4a2c3

See more details on using hashes here.

File details

Details for the file proxyrequest-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: proxyrequest-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for proxyrequest-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5d5f74e137dd3c9a0a800496b64df9c4e4cc026c8e66d71e1b334c950a6693
MD5 ee5d7e3c2ef0034ac1ae0b193952c349
BLAKE2b-256 3dff494c989e9c69a638d1d8a51f47c22f5ac05375c4373bb60e203dd2875481

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