-
-
Save AnderRV/22c4e888e547a1bcd029038a4122f730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from redis import Redis | |
from tasks import crawl | |
connection = Redis(db=1) | |
starting_url = 'https://scrapeme.live/shop/page/1/' | |
connection.rpush('crawling:to_visit', starting_url) | |
while True: | |
# timeout after 1 minute | |
item = connection.blpop('crawling:to_visit', 60) | |
if item is None: | |
print('Timeout! No more items to process') | |
break | |
url = item[1].decode('utf-8') | |
print('Pop URL', url) | |
crawl.delay(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment