Skip to content

Instantly share code, notes, and snippets.

@orangepeelbeef
Last active May 22, 2020 14:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save orangepeelbeef/357ebe94a0251bca7e1812982cc732d7 to your computer and use it in GitHub Desktop.
Save orangepeelbeef/357ebe94a0251bca7e1812982cc732d7 to your computer and use it in GitHub Desktop.
Collect sony ps now games and show which ones have local / online co-op
#!/usr/bin/python3
import bs4
import requests
import urllib
COUCH_COOP = []
NET_COOP = []
def print_output(collection):
for _c in collection:
print("Title: {}\tSystem: {}\tPlayers: {}".format(_c['title'], _c['system'], _c['players']))
def check_cooptimus(title):
r = requests.get("http://api.co-optimus.com/games.php?search=true&name={}".format(
urllib.parse.quote(title)))
soup = bs4.BeautifulSoup(r.text, 'html.parser')
for _g in soup.find_all('game'):
# we only want results that are exact matches
if title == _g.title.get_text():
# we only want results that are ps3 or ps4
if _g.system.get_text() == 'Playstation 3' or \
_g.system.get_text() == 'Playstation 4':
# if <local> > 0 add to couch_coop array
if int(_g.local.get_text()) > 0:
COUCH_COOP.append({ 'title': _g.title.get_text(), 'system': _g.system.get_text(),
'players': _g.local.get_text()
} )
# if <online> > 0 add to net_coop array
if int(_g.online.get_text()) > 0:
NET_COOP.append({ 'title': _g.title.get_text(), 'system': _g.system.get_text(),
'players': _g.online.get_text()
})
r = requests.get('https://www.playstation.com/en-us/explore/psnow/games/')
soup = bs4.BeautifulSoup(r.text, 'html.parser')
for _title in soup.find_all("li", class_="game-title"):
if _title:
check_cooptimus(_title.get_text())
print("COUCH Co-OP")
print_output(COUCH_COOP)
print("ONLINE Co-OP")
print_output(NET_COOP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment