Skip to content

Commit

Permalink
Add max attempts for exam requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kashav committed Apr 20, 2016
1 parent 26fe823 commit fac88e8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions uoftscrapers/scrapers/exams/utsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ def scrape(location='.', year=None):
'Referer': UTSGExams.host
}
html = Scraper.get('%s%s' % (UTSGExams.host, p),
headers=headers)
soup = BeautifulSoup(html, 'html.parser')
headers=headers,
max_attempts=3)

if not soup.find('table', class_='vertical listing'):
try:
soup = BeautifulSoup(html, 'html.parser')
except TypeError:
soup = None

if not (html and soup and soup.find(class_='vertical listing')):
# no exam data available
Scraper.logger.info('No %s exams.' % p.upper())
continue
Expand Down

0 comments on commit fac88e8

Please sign in to comment.