Metadata-Version: 2.4
Name: pxm2-selenium
Version: 1.0.0
Summary: Official Selenium WebDriver & Selenium-Wire proxy extension injector and mobile rotator for PXM2 4G/5G mobile proxies.
Author-email: PXM2 Team <support@pxm2.io>
License-Expression: MIT
Project-URL: Homepage, https://pxm2.io/
Project-URL: Documentation, https://pxm2.io/guides/
Project-URL: Rotating Mobile Proxies, https://pxm2.io/proxy-types/rotating-mobile-proxies/
Project-URL: Bug Tracker, https://pxm2.io/contact/
Keywords: selenium,selenium-wire,proxy,mobile-proxy,rotating-proxy,pxm2,web-scraping,automation
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# PXM2 Selenium Helper

[![PyPI version](https://img.shields.io/pypi/v/pxm2-selenium.svg)](https://pypi.org/project/pxm2-selenium/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
[![Selenium](https://img.shields.io/badge/selenium-4.0%2B-green.svg)](https://www.selenium.dev/)

Official Selenium WebDriver and Selenium-Wire proxy helper for [PXM2](https://pxm2.io/) dedicated 4G and 5G cellular mobile proxies.

Standard Selenium Chrome does not support authenticated proxies via command-line arguments. `pxm2-selenium` solves this by automatically generating a lightweight in-memory background extension that handles Chrome proxy authentication seamlessly, while also offering instant modem IP rotation.

For full setup walk-throughs and code samples, check out the [PXM2 Integration Guides](https://pxm2.io/guides/).

---

## Features

- **Automatic Chrome Proxy Extension Injection**: Solves Selenium Chrome proxy authentication by generating signed proxy extensions on the fly.
- **Selenium-Wire Compatibility**: Ready-to-use proxy configuration dictionary for `seleniumwire.webdriver`.
- **Hardware IP Rotation**: Trigger 1-click cellular modem reconnect webhooks directly from Python with automated reconnection cooldown.
- **In-flight IP Inspection**: Check your current mobile CGNAT IP through the proxy using Python stdlib.
- **Zero Heavy Dependencies**: Pure standard library implementation.

---

## Installation

```bash
pip install pxm2-selenium
```

---

## Usage

### 1. Standard Selenium WebDriver (with Auto Chrome Extension)

```python
from selenium import webdriver
from pxm2_selenium import PXM2Selenium

# Initialize PXM2 client
pxm = PXM2Selenium(
    host="proxy.pxm2.io",
    port=10001,
    username="your_username",
    password="your_password",
    rotation_url="https://api.pxm2.io/rotate/YOUR_API_TOKEN",
    cooldown=6.0
)

options = webdriver.ChromeOptions()
# Automatically injects proxy credentials extension into Chrome
pxm.apply_to_chrome_options(options)

driver = webdriver.Chrome(options=options)
driver.get("https://api.ipify.org?format=json")
print("Initial IP:", driver.page_source)

# Trigger instant physical mobile IP rotation
print("Rotating mobile IP...")
pxm.rotate()

driver.get("https://api.ipify.org?format=json")
print("Rotated IP:", driver.page_source)

driver.quit()
```

---

### 2. Selenium-Wire

```python
from seleniumwire import webdriver
from pxm2_selenium import PXM2Selenium

pxm = PXM2Selenium(
    host="proxy.pxm2.io",
    port=10001,
    username="your_username",
    password="your_password",
    rotation_url="https://api.pxm2.io/rotate/YOUR_API_TOKEN",
    cooldown=6.0
)

# Launch Selenium-Wire with PXM2 mobile proxy
driver = webdriver.Chrome(seleniumwire_options=pxm.selenium_wire_options())

driver.get("https://httpbin.org/ip")
print("Current IP:", driver.page_source)

# Rotate IP on demand
pxm.rotate()
driver.get("https://httpbin.org/ip")
print("Rotated IP:", driver.page_source)

driver.quit()
```

---

## Why PXM2 4G/5G Mobile Proxies?

Unlike datacenter or common residential proxy networks that suffer from frequent subnet bans and CAPTCHA challenges, [PXM2](https://pxm2.io/) uses dedicated physical cellular modems with SIM cards from major mobile carriers.

Because cellular networks route thousands of legitimate mobile phones through shared Carrier-Grade NAT (CGNAT) pools, anti-bot engines (DataDome, Cloudflare, PerimeterX) cannot ban these IPs without blocking real consumer traffic.

Explore more resources:
- [PXM2 Official Website](https://pxm2.io/)
- [Rotating Mobile Proxies](https://pxm2.io/proxy-types/rotating-mobile-proxies/)
- [Step-by-Step Setup Guides](https://pxm2.io/guides/)
- [Contact Support](https://pxm2.io/contact/)

---

## License

MIT License. See [LICENSE](LICENSE) for details.
