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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swiftshadow
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Free IP Proxy rotator for python
5
5
  Home-page: https://github.com/sachin-sankar/swiftshadow
6
6
  Author: Sachin Sankar
@@ -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.0"),
28
+ version=VERSION.get("__version__", "0.2.1"),
29
29
  packages=find_packages(where=".", exclude=["tests"]),
30
30
  install_requires=["requests"],
31
31
  classifiers=[
@@ -4,7 +4,7 @@ from time import sleep
4
4
 
5
5
  def getExpiry(expiryIn):
6
6
  now = datetime.now(timezone.utc)
7
- expiry = now + timedelta(minutes=expiryIn)
7
+ expiry = now + timedelta(seconds=expiryIn)
8
8
  return expiry
9
9
 
10
10
 
@@ -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 pickle import dump, load
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 minutes.
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.dat", "rb") as file:
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.dat", "wb") as file:
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swiftshadow
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Free IP Proxy rotator for python
5
5
  Home-page: https://github.com/sachin-sankar/swiftshadow
6
6
  Author: Sachin Sankar
File without changes
File without changes
File without changes