Advertisement
Guest User

sequential.py

a guest
Apr 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import requests
  2. import json
  3. import time
  4. from datetime import datetime
  5.  
  6. with open('urls.json', 'r') as f:
  7.     urls = json.loads(f.read())
  8.  
  9. start = int(time.time())
  10.  
  11. for counter, url in enumerate(urls):
  12.     r = requests.get(url['url'])
  13.     mystring = '{}. {}: {}'.format(counter + 1, url['title'], r.status_code)
  14.     print(mystring)
  15.  
  16. end = int(time.time())
  17.  
  18. print('took time: {} seconds'.format(int(end - start)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement