Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import aiohttp
- from collections import namedtuple
- import datetime
- entries = []
- url = 'https://gamesdonequick.com/tracker/runs/sgdq2018'
- MarathonEntry = namedtuple('MarathonEntry', ('game', 'category', 'runner', 'estimate', 'starttime'))
- headers = {'User-Agent': '<your user agent here>'}
- async with aiohttp.ClientSession(headers=headers) as session:
- async with session.get(url) as req:
- pagehtml = await req.text()
- entries = []
- soup = BeautifulSoup(pagehtml, 'html.parser')
- for row in soup.find_all('tr'):
- elts = row.find_all('td')
- if len(elts) != 6: continue
- GDQ_TSFORMAT = '%m/%d/%Y %H:%M:%S %z'
- timestamp_s = datetime.datetime.strptime(elts[3].get_text().strip(), GDQ_TSFORMAT)
- timestamp_e = datetime.datetime.strptime(elts[4].get_text().strip(), GDQ_TSFORMAT)
- runner = elts[1].get_text().strip()
- game = elts[0].get_text().strip()
- category = elts[2].get_text().strip()
- estimate = timestamp_e - timestamp_s
- entries.append(MarathonEntry(game=game,
- category=category,
- runner=runner,
- estimate=estimate,
- starttime=timestamp_s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement