Skip to content

Commit

Permalink
fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
theslavicbear committed Aug 11, 2020
1 parent ec330ec commit 159f81e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Site/Common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, urllib, os, requests
import sys, urllib, os, requests, time

#Module contains common functions needed by sites

Expand Down Expand Up @@ -61,6 +61,7 @@ def GetImage(url):
elif url[-4:]=='.png':
req = urllib.request.Request(url[:-4]+'.jpg', headers={'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'})
return urllib.request.urlopen(req).read()

class Progress:

size=0
Expand Down Expand Up @@ -93,13 +94,13 @@ def RequestSend(url, headers=None):

def RequestPage(url, headers=None):
response = RequestSend(url, headers)

attempts = 0
while response.status_code != 200 and attempts < 4:
time.sleep(2)
response = RequestSend(url, headers)
attempts +=1
if attempts => 5:
print("Server returned status code: " + response.status_code)
if attempts >= 4:
print("Server returned status code " + str(response.status_code) +' for page: ' +url)
return None
return response

Expand Down

0 comments on commit 159f81e

Please sign in to comment.