pxm2 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pxm2/__init__.py ADDED
@@ -0,0 +1,58 @@
1
+ """
2
+ PXM2 Official Python Client & Helper
3
+ High-performance 4G/5G mobile proxy management with instant IP rotation.
4
+ Website: https://pxm2.io/
5
+ """
6
+
7
+ import urllib.request
8
+ import json
9
+ from typing import Optional, Dict
10
+
11
+ __version__ = "1.0.0"
12
+ __author__ = "PXM2 Network Engineering Team"
13
+
14
+ class PXM2Proxy:
15
+ """Helper to configure and rotate PXM2 4G/5G mobile proxies."""
16
+ def __init__(self, host: str, port: int, username: str, password: str, rotation_url: Optional[str] = None):
17
+ self.host = host
18
+ self.port = port
19
+ self.username = username
20
+ self.password = password
21
+ self.rotation_url = rotation_url
22
+
23
+ @property
24
+ def http_url(self) -> str:
25
+ return f"http://{self.username}:{self.password}@{self.host}:{self.port}"
26
+
27
+ @property
28
+ def socks5_url(self) -> str:
29
+ return f"socks5://{self.username}:{self.password}@{self.host}:{self.port}"
30
+
31
+ def for_requests(self) -> Dict[str, str]:
32
+ """Returns proxy dictionary for requests library."""
33
+ url = self.http_url
34
+ return {"http": url, "https": url}
35
+
36
+ def for_httpx(self) -> str:
37
+ """Returns proxy URL formatted for httpx."""
38
+ return self.http_url
39
+
40
+ def for_playwright(self) -> Dict[str, str]:
41
+ """Returns proxy dictionary formatted for Playwright browser launch."""
42
+ return {
43
+ "server": f"http://{self.host}:{self.port}",
44
+ "username": self.username,
45
+ "password": self.password
46
+ }
47
+
48
+ def rotate_ip(self, timeout: int = 15) -> Dict[str, str]:
49
+ """Triggers 1-click mobile IP rotation via PXM2 webhook."""
50
+ if not self.rotation_url:
51
+ raise ValueError("No rotation_url provided for this proxy instance.")
52
+ req = urllib.request.Request(self.rotation_url, headers={"User-Agent": f"pxm2-python/{__version__}"})
53
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
54
+ content = resp.read().decode('utf-8')
55
+ try:
56
+ return json.loads(content)
57
+ except Exception:
58
+ return {"status": "success", "raw": content.strip()}
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: pxm2
3
+ Version: 1.0.0
4
+ Summary: Official Python client and proxy rotator for PXM2 4G/5G mobile proxies.
5
+ Author-email: PXM2 Team <support@pxm2.io>
6
+ Project-URL: Homepage, https://pxm2.io/
7
+ Project-URL: Documentation, https://pxm2.io/guides/
8
+ Project-URL: Mobile Proxies, https://pxm2.io/proxy-types/rotating-mobile-proxies/
9
+ Project-URL: Bug Tracker, https://pxm2.io/contact/
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Internet :: Proxy Servers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+
18
+ # PXM2 Python Client & Proxy Rotator
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/pxm2.svg)](https://pypi.org/project/pxm2/)
21
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
22
+
23
+ Official lightweight Python helper for [PXM2](https://pxm2.io/) dedicated 4G and 5G mobile proxies.
24
+
25
+ Easily integrate rotating mobile proxies into **Requests**, **HTTPX**, **Playwright**, and **Selenium** with instant 1-click IP rotation webhooks.
26
+
27
+ ---
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install pxm2
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Quickstart
38
+
39
+ ### 1. Configure Proxy & Rotate IP
40
+
41
+ ```python
42
+ from pxm2 import PXM2Proxy
43
+ import requests
44
+
45
+ # Initialize your PXM2 mobile proxy
46
+ proxy = PXM2Proxy(
47
+ host="proxy.pxm2.io",
48
+ port=10001,
49
+ username="pxm_user",
50
+ password="pxm_password",
51
+ rotation_url="https://api.pxm2.io/rotate/user_token_here"
52
+ )
53
+
54
+ # 1. Use with requests
55
+ resp = requests.get("https://httpbin.org/ip", proxies=proxy.for_requests())
56
+ print("Current IP:", resp.json())
57
+
58
+ # 2. Trigger instant IP rotation on physical 4G/5G modem
59
+ result = proxy.rotate_ip()
60
+ print("Rotation result:", result)
61
+ ```
62
+
63
+ ### 2. Integration with Playwright
64
+
65
+ ```python
66
+ from playwright.sync_api import sync_playwright
67
+ from pxm2 import PXM2Proxy
68
+
69
+ proxy = PXM2Proxy(
70
+ host="proxy.pxm2.io",
71
+ port=10001,
72
+ username="pxm_user",
73
+ password="pxm_password"
74
+ )
75
+
76
+ with sync_playwright() as p:
77
+ browser = p.chromium.launch(
78
+ proxy=proxy.for_playwright(),
79
+ headless=False
80
+ )
81
+ page = browser.new_page()
82
+ page.goto("https://browserleaks.com/ip")
83
+ browser.close()
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Why PXM2?
89
+
90
+ [PXM2](https://pxm2.io/) provides dedicated physical cellular SIM modems with carrier CGNAT IP pools:
91
+ - 100% genuine mobile IPs (AT&T, Verizon, Vodafone, Movistar, Orange, EE).
92
+ - Instant hardware rotation (under 8 seconds).
93
+ - Unmetered bandwidth with zero data caps.
94
+ - Learn more at [PXM2 Rotating Mobile Proxies](https://pxm2.io/proxy-types/rotating-mobile-proxies/).
95
+
96
+ ---
97
+
98
+ ## Documentation & Guides
99
+
100
+ - Official Website: [https://pxm2.io/](https://pxm2.io/)
101
+ - Integration Guides: [https://pxm2.io/guides/](https://pxm2.io/guides/)
102
+ - API Reference: [https://pxm2.io/docs/](https://pxm2.io/docs/)
@@ -0,0 +1,5 @@
1
+ pxm2/__init__.py,sha256=EhFhNrXFziuxE75trB_SyhnZbJLa-X4XFrfVytJQKiE,2111
2
+ pxm2-1.0.0.dist-info/METADATA,sha256=kpOAk5MRyMOzyW_mx4KeKdS7s4ZuEMHWVYYPVhC-DW8,2930
3
+ pxm2-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
4
+ pxm2-1.0.0.dist-info/top_level.txt,sha256=exbkvFjK5FLOZMfjD1K4aJNx1ICU755pi_IZbSGu6M8,5
5
+ pxm2-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pxm2