Add class #1
31
scraper/scraper.py
Normal file
31
scraper/scraper.py
Normal file
@ -0,0 +1,31 @@
|
||||
import pybomb
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
class GameSearch:
|
||||
def __init__(self, api_key):
|
||||
self.games_client = pybomb.GamesClient(api_key)
|
||||
|
||||
def quick_search(self, name, platform=None):
|
||||
response = self.games_client.quick_search(
|
||||
name=name.strip(),
|
||||
platform=platform,
|
||||
sort_by='original_release_date',
|
||||
desc=True
|
||||
)
|
||||
return response
|
||||
|
||||
def get_name(self, response):
|
||||
return response.results[0]['name']
|
||||
|
||||
def get_overview(self, response):
|
||||
description_html = response.results[0]['description']
|
||||
soup = BeautifulSoup(description_html, 'html.parser')
|
||||
overview_heading = soup.find('h2', string='Overview')
|
||||
overview_text = overview_heading.find_next_sibling().get_text()
|
||||
return overview_text
|
||||
|
||||
def get_icon_url(self, response):
|
||||
return response.results[0]['image']['icon_url']
|
||||
|
||||
def get_deck(self, response):
|
||||
return response.results[0]['deck']
|
||||
Loading…
x
Reference in New Issue
Block a user