swiftshadow 0.2.0__py3-none-any.whl → 0.2.1__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.
- swiftshadow/cache.py +1 -1
- swiftshadow/swiftshadow.py +7 -14
- {swiftshadow-0.2.0.dist-info → swiftshadow-0.2.1.dist-info}/METADATA +1 -1
- swiftshadow-0.2.1.dist-info/RECORD +11 -0
- swiftshadow-0.2.0.dist-info/RECORD +0 -11
- {swiftshadow-0.2.0.dist-info → swiftshadow-0.2.1.dist-info}/LICENSE +0 -0
- {swiftshadow-0.2.0.dist-info → swiftshadow-0.2.1.dist-info}/WHEEL +0 -0
- {swiftshadow-0.2.0.dist-info → swiftshadow-0.2.1.dist-info}/top_level.txt +0 -0
swiftshadow/cache.py
CHANGED
swiftshadow/swiftshadow.py
CHANGED
@@ -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)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
swiftshadow/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
2
|
+
swiftshadow/cache.py,sha256=h7eRafFVFWB9ArhaoB-nRllMBOGj4lPB2r88LC-diV8,370
|
3
|
+
swiftshadow/constants.py,sha256=FRhoYg8WNaLy8RLDD4BsANlXlY2tctBCdy7sCnkaVY0,6303
|
4
|
+
swiftshadow/helpers.py,sha256=8Sd_1FRf9wRO7mhQ42OooRJVGhOp9xVQqQYeza0_2sI,807
|
5
|
+
swiftshadow/providers.py,sha256=DpT13HtBC0VNC-SrVV-cxd-UXgJ68itxStLDZLmU5tE,1524
|
6
|
+
swiftshadow/swiftshadow.py,sha256=RxNS5YDmMtBPlb1ESsv3jj0KmaVSACjQOdkgZzB0sPw,4411
|
7
|
+
swiftshadow-0.2.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
8
|
+
swiftshadow-0.2.1.dist-info/METADATA,sha256=0pJvswxBMNnLAwfwnJCXJC9YvyAKDpRGz4fO2MbPOnE,2640
|
9
|
+
swiftshadow-0.2.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
10
|
+
swiftshadow-0.2.1.dist-info/top_level.txt,sha256=GClzVDF5vWSzqHOwgG2ycQAAJXRxd-QOdP1h3YrHOuM,12
|
11
|
+
swiftshadow-0.2.1.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
swiftshadow/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
2
|
-
swiftshadow/cache.py,sha256=raLWKjsT2tn6OCnxq1y1g8zhceeG0eDVAa4VGp1omVU,370
|
3
|
-
swiftshadow/constants.py,sha256=FRhoYg8WNaLy8RLDD4BsANlXlY2tctBCdy7sCnkaVY0,6303
|
4
|
-
swiftshadow/helpers.py,sha256=8Sd_1FRf9wRO7mhQ42OooRJVGhOp9xVQqQYeza0_2sI,807
|
5
|
-
swiftshadow/providers.py,sha256=DpT13HtBC0VNC-SrVV-cxd-UXgJ68itxStLDZLmU5tE,1524
|
6
|
-
swiftshadow/swiftshadow.py,sha256=SLxDNJ6THtZZ-KR4nGl_bBPkdkHSQ3gGPwKjESuzFRA,4487
|
7
|
-
swiftshadow-0.2.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
8
|
-
swiftshadow-0.2.0.dist-info/METADATA,sha256=YySzVK_TUCLKRAJD-G6p9uNgpR9j5F5TI2tV7SEaoGs,2640
|
9
|
-
swiftshadow-0.2.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
10
|
-
swiftshadow-0.2.0.dist-info/top_level.txt,sha256=GClzVDF5vWSzqHOwgG2ycQAAJXRxd-QOdP1h3YrHOuM,12
|
11
|
-
swiftshadow-0.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|