-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlanguages.py
More file actions
38 lines (28 loc) · 1018 Bytes
/
languages.py
File metadata and controls
38 lines (28 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from bs4 import BeautifulSoup
import requests
id_file = open('id_mappings.txt', 'r', encoding='utf-8')
languages_file = open('test_languages.txt', 'w', encoding='utf-8')
for line in id_file:
if line == '':
continue
elif line == '+':
continue
game_name = line.split(',')[0]
game_id = line.split(',')[1]
languages_file.write('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
languages_file.write(game_name + ', ' + game_id)
print(game_name + ', ' + game_id)
URL = 'https://store.steampowered.com/app/' + game_id
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
language_table = soup.find(class_='game_language_options')
#print(language_table)
if language_table is None:
continue
languages = language_table.find_all(class_='ellipsis')
for language in languages:
if language == '':
continue
languages_file.write(language.text.strip() + '\n')
languages_file.close()
id_file.close()