Merge pull request 'Add class' (#1) from feature/scraper into master
Reviewed-on: #1 Looks good lgtm
This commit is contained in:
commit
8a5dc238a1
2
scraper/requirements.txt
Normal file
2
scraper/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
beautifulsoup4==4.12.2
|
||||
pybomb==0.4.0
|
||||
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