-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathasync_test.py
More file actions
executable file
·37 lines (26 loc) · 875 Bytes
/
async_test.py
File metadata and controls
executable file
·37 lines (26 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import grequests
import posts
from medium_crawler import LinkFetcher
class Test:
def __init__(self):
# link_fetcher = LinkFetcher('headless', username='nishparadox')
# self.urls = link_fetcher.get_links()
self.urls = [
"https://psiloveyou.xyz/tonight-300de7515249",
"https://medium.com/@nishparadox/the-sound-of-life-ffb582f060de"
]
print(self.urls)
def exception(self, request, exception):
print("Problem: {}: {}".format(request.url, exception))
def get(self, url):
print(url)
return grequests.get(url)
def async(self):
results = grequests.map((self.get(u) for u in self.urls), exception_handler=self.exception, size=5)
print(results)
def main():
test = Test()
test.async()
if __name__ == "__main__":
main()