swiftshadow 0.2.0__tar.gz → 0.2.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {swiftshadow-0.2.0/swiftshadow.egg-info → swiftshadow-0.2.1}/PKG-INFO +1 -1
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/setup.py +1 -1
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/cache.py +1 -1
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/swiftshadow.py +7 -14
- {swiftshadow-0.2.0 → swiftshadow-0.2.1/swiftshadow.egg-info}/PKG-INFO +1 -1
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/LICENSE +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/README.md +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/setup.cfg +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/__init__.py +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/constants.py +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/helpers.py +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow/providers.py +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow.egg-info/SOURCES.txt +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow.egg-info/dependency_links.txt +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow.egg-info/requires.txt +0 -0
- {swiftshadow-0.2.0 → swiftshadow-0.2.1}/swiftshadow.egg-info/top_level.txt +0 -0
@@ -25,7 +25,7 @@ setup(
|
|
25
25
|
description="Free IP Proxy rotator for python",
|
26
26
|
long_description=long_description,
|
27
27
|
long_description_content_type="text/markdown",
|
28
|
-
version=VERSION.get("__version__", "0.2.
|
28
|
+
version=VERSION.get("__version__", "0.2.1"),
|
29
29
|
packages=find_packages(where=".", exclude=["tests"]),
|
30
30
|
install_requires=["requests"],
|
31
31
|
classifiers=[
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from requests import get
|
2
2
|
from random import choice
|
3
3
|
from datetime import datetime, timezone, timedelta
|
4
|
-
from
|
4
|
+
from json import dump, load
|
5
5
|
from swiftshadow.helpers import log
|
6
6
|
from swiftshadow.providers import Proxyscrape, Scrapingant
|
7
7
|
import swiftshadow.cache as cache
|
@@ -26,7 +26,7 @@ class Proxy:
|
|
26
26
|
protocol: HTTP/HTTPS protocol to filter proxies.
|
27
27
|
maxProxies: Maximum number of proxies to store and rotate from.
|
28
28
|
autoRotate: Rotates proxy when `Proxy.proxy()` function is called.
|
29
|
-
cachePeriod: Time to cache proxies in
|
29
|
+
cachePeriod: Time to cache proxies in seconds.
|
30
30
|
|
31
31
|
Returns:
|
32
32
|
proxyClass (swiftshadow.Proxy): `swiftshadow.Proxy` class instance
|
@@ -45,6 +45,7 @@ class Proxy:
|
|
45
45
|
self.maxProxies = maxProxies
|
46
46
|
self.autoRotate = autoRotate
|
47
47
|
self.cachePeriod = cachePeriod
|
48
|
+
|
48
49
|
self.update()
|
49
50
|
|
50
51
|
def checkIp(self, ip, cc, protocol):
|
@@ -63,9 +64,9 @@ class Proxy:
|
|
63
64
|
|
64
65
|
def update(self):
|
65
66
|
try:
|
66
|
-
with open(".swiftshadow.
|
67
|
+
with open(".swiftshadow.json", "r") as file:
|
67
68
|
data = load(file)
|
68
|
-
self.expiry = data[0]
|
69
|
+
self.expiry = datetime.fromisoformat(data[0])
|
69
70
|
expired = cache.checkExpiry(self.expiry)
|
70
71
|
if not expired:
|
71
72
|
log(
|
@@ -95,8 +96,8 @@ class Proxy:
|
|
95
96
|
"No proxies found for current settings. To prevent runtime error updating the proxy list again.",
|
96
97
|
)
|
97
98
|
self.update()
|
98
|
-
with open(".swiftshadow.
|
99
|
-
dump([cache.getExpiry(self.cachePeriod), self.proxies], file)
|
99
|
+
with open(".swiftshadow.json", "w") as file:
|
100
|
+
dump([cache.getExpiry(self.cachePeriod).isoformat(), self.proxies], file)
|
100
101
|
self.current = self.proxies[0]
|
101
102
|
|
102
103
|
def rotate(self):
|
@@ -125,11 +126,3 @@ class Proxy:
|
|
125
126
|
return choice(self.proxies)
|
126
127
|
else:
|
127
128
|
return self.current
|
128
|
-
|
129
|
-
|
130
|
-
from time import sleep
|
131
|
-
|
132
|
-
a = Proxy(cachePeriod=1, maxProxies=1)
|
133
|
-
while True:
|
134
|
-
print(a.proxy())
|
135
|
-
sleep(1)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|