luckyluke
luckyluke

Reputation: 654

Delay/defer functionality in jupyter notebook

Trying to scrape a list of websites from jupyter notebook and below is the snippet

import requests as rqst
from bs4 import BeautifulSoup

urllist = [ list of urls both http and https]

results = []
for i in urllist:
    print(i)
    pagecontent = rqst.get(i)
    if (pagecontent.status_code == 200):
        results.append(pagecontent)

Is there a way to make the execution to wait for few seconds/ until a status_code is available before moving to the next iteration?

Upvotes: 0

Views: 1071

Answers (1)

Alex Metsai
Alex Metsai

Reputation: 1950

You can always use time.sleep().

import time

# Wait 5 seconds
time.sleep(5)

Upvotes: 1

Related Questions