Skip to content

Instantly share code, notes, and snippets.

@AnderRV

AnderRV/main.py Secret

Created August 20, 2021 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnderRV/22c4e888e547a1bcd029038a4122f730 to your computer and use it in GitHub Desktop.
Save AnderRV/22c4e888e547a1bcd029038a4122f730 to your computer and use it in GitHub Desktop.
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