Skip to content

Instantly share code, notes, and snippets.

@mottet-dev
Created February 6, 2019 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottet-dev/97b746f0385e50da049204eeaa57c4ac to your computer and use it in GitHub Desktop.
Save mottet-dev/97b746f0385e50da049204eeaa57c4ac to your computer and use it in GitHub Desktop.
Real Time Scraping - after
class SteamSearch(Resource):
def put(self):
r = requests.get('https://store.steampowered.com/search/?term=The+witcher')
soup = BeautifulSoup(r.text, 'html.parser')
resultsRow = soup.find_all('a', {'class': 'search_result_row'})
results = []
for resultRow in resultsRow:
gameURL = resultRow.get('href')
title = resultRow.find('span', {'class': 'title'}).text
releaseDate = resultRow.find('div', {'class': 'search_released'}).text
imgURL = resultRow.select('div.search_capsule img')[0].get('src')
price = None
discountedPrice = None
if (resultRow.select('div.search_price span strike')):
price = resultRow.select('div.search_price span strike')[
0].text.strip(' \t\n\r')
if (resultRow.select('div.search_price')):
rawDiscountPrice = resultRow.select(
'div.search_price')[0].text.strip(' \t\n\r')
discountedPrice = rawDiscountPrice.replace(price, '')
# Once formatted, the data are then appended to the results list
results.append({
'gameURL': gameURL,
'title': title,
'releaseDate': releaseDate,
'imgURL': imgURL,
'price': price,
'discountedPrice': discountedPrice
})
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment