GameIndustry.eu Logo

2019 2017 2019 2019   2018  2023   2015 
GameIndustry.eu /  Blog /
EnglishPython - Extract Steamgames


Python - Extract Steamgames

Eingetragen: 24.08.2023 Editiert: 03.02.2024

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

Changes 03.02.2024
- Redunant code removed
- The number of products found is now also displayed

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
    import datetime

    def parse_and_output_xml(filename):
    if not os.path.exists(filename):
    print(f'File {filename} does not exist.')
    return

    mod_time = os.path.getmtime(filename)
    mod_date = datetime.datetime.fromtimestamp(mod_time).strftime('%d-%m-%Y')

    try:
    tree = ET.parse(filename)
    root = tree.getroot()
    steam_id = root.find('steamID').text if root.find('steamID') is not None else "Unknown"

    game_list = sorted([game.find('name').text for game in root.findall('.//game') if game.find('name') is not None])
    games_count = len(game_list) # Number of titles found

    output_filename = f'{steam_id}-Steamgames-{mod_date}.txt'

    with open(output_filename, 'w', encoding='utf-8') as output_file:
    # Inclusion of the number of titles found in the output
    output_file.write(f'Steam-Games from {steam_id} - Date: {mod_date} - Titles: {games_count}\n\n')
    output_file.write('\n'.join(game_list))

    print(f'The games were saved in the file "{output_filename}".')
    except ET.ParseError:
    print("Error parsing the XML file.")
    except Exception as e:
    print(f"An unexpected error has occurred: {e}")

    if __name__ == "__main__":
    parse_and_output_xml('steamcommunity.com.xml')

  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.

 

  Download Script

 

spieleliste.py (1.36 KB)
Date: 2025-01-29
CRC32 Hash: 659b0aaa
SHA-256 Hash: fd339736dc461d5001e77dcaf6d537b5f859c2a46c47911fd2624ff6bccc63fa

 

 

Your opinion is important – please leave a comment!

×

BB-Code Explanations

Here are the BB-Codes you can use:

  • [b] for bold text: [b]Text[/b] turns into Text
  • [i] for italic text: [i]Text[/i] turns into Text
  • [u] for underlined text: [u]Text[/u] turns into Text
  • [spoiler] for hidden Text: [spoiler]Hidden Text[/spoiler] turns into Hidden Text
  • [url] for hyperlinks: [url]http://example.com[/url] becomes a clickable link  
  • [url=link]text[/url] for named hyperlinks: [url=http://example.com]Visit me[/url] turns into Visit me  
  • [github] for GitHub links: [github]http://github.com/example[/github] turns into a  GitHub-Link

0 Comments