Files
scripts/python/web/gogdb_scaper.py
2019-04-13 22:28:43 +03:00

24 lines
796 B
Python
Executable File

#!/usr/bin/env python3
import requests # http requests
import bs4 # html parser
with open("titles.txt", "w", encoding="UTF-8") as file:
for index in range(1, 175):
url = "https://www.gogdb.org/products?page=" + str(index)
print(url)
page = requests.get("https://www.gogdb.org/products?page=" + str(index))
page.raise_for_status()
soup = bs4.BeautifulSoup(page.text, "html.parser")
producttable = soup.select("#product-table")[0]
titles = producttable.select("tr")
for title in titles:
if len(title.select(".col-type")) == 0:
continue
if title.select(".col-type")[0].text == 'Game':
file.write(title.select(".col-name")[0].text.strip() + '\n')