GameIndustry.eu /  Blog /
EnglishPython - Extract Steamgames


Python - Extract Steamgames

Eingetragen: 24.08.2023

python
Python Script: The script has the task of extracting data from the previously saved game list of your own Steam account and writing it to a text file. Extracted titles are sorted alphabetically and the created file is given a date.

For large collections, this can be helpful to keep an eye on your own titles and DLCs.



An existing installation of Python is required

First of all, the Steam server must call up and save its own game list in XML format. For the following explanation it is assumed that the files are located in the folder "c :\game list" You can of course freely choose the storage location.
  1. Go to link:
    "https://steamcommunity.com/id/XXX/games/?tab=all&xml=1"

    Replace XXX with your own ID. You can see your own ID in the URL line of your Steam profile.

    My XML file can be found as an example via "https://steamcommunity.com/id/pen-chan/games/?tab=all&xml=1"

  2. Right click, save page as "steamcommunity.com.xml"
  3. and save the Python script. e.g. as "spieleliste.py"

  4.  import xml.etree.ElementTree as ET
    import os.path
    import datetime

    # Step 1: Reading XML file
    tree = ET.parse('steamcommunity.com.xml')
    root = tree.getroot()

    # Step 2: Extract SteamID
    steam_id = root.find('steamID').text

    # Step 3: Determine modification date of file 'steamcommunity.com.xml'
    mod_time = os.path.getmtime('steamcommunity.com.xml')
    mod_date = datetime.datetime.fromtimestamp(mod_time).strftime('%d-%m-%Y')

    # Step 4: Create and write file for the found games
    output_filename = f'{steam_id}-Steamgames-{mod_date}.txt'

    with open(output_filename, 'w', encoding='utf-8') as output_file:
    # Step 5: Extract heading and games and write sorted into the file
    game_list = sorted([game.find('name').text for game in root.findall('.//game')])
    output_file.write(f'Steamgames from {steam_id} - Date: {mod_date}\n\n')
    output_file.write('\n'.join(game_list))

    # Optional screen feedback
    print(f'The games were saved in "{output_filename}".')

  5. Move the "spieleliste.py" and "steamcommunity.com.xml" you just created to the "c :\game list" folder
  6. Launch the Windows Command Prompt (CMD) via the "Windows + R key" or via the Start menu and enter "cmd"
  7. Navigate to folder "c :\game list" enter and confirm the following

 python spieleliste.py

The script runs, reading the data from the "steamcommunity.com.xml" and summarizes the results alphabetically in a text file. In my case, the "ペンギン -Steamspiele-14-08-2023.txt" would list 6979 purchased products that are currently in my own Steam library.

Alternate download of the script
spieleliste.py (1.02 KB)
Date: 2023-09-05
CRC32 Hash: bff15c2e
SHA-256 Hash: ba166678a18d40299ba1eea14f49846d715f337521864c5b900482d6881f343b

 

 

  Rules for posting comments can be found in the F.A.Q.