0

I want to make an application that can tell you the Steam AppID when you insert the name of the game as input, but I do not know how to display the name of the game selected and the AppID properly to the user.

The AppID and the Game's name is on this format: {"appid":000000,"name":"Game_Name"}. What I want to communicate then, is the "Game Name" and then the number of the appid right after it.

Here's the code I got thus far, I got another code for a GUI, this is the fetcher from which I would import the data, I'm planning on calling the input from the GUI as the Game_Fetched variable.

while True:
import requests
from bs4 import BeautifulSoup

# Definitions
SteamAPI = 'https://api.steampowered.com/ISteamApps/GetAppList/v2/'
response = requests.get(SteamAPI)
soup = BeautifulSoup(response.text, "html.parser")
Game_List = str(soup)
Line = 'Undefined'

# Start of script
print('Game to be fetched')
Game_fetched = input()

if str(Game_fetched) in Game_List:
 **(Uncertain)**
if Line == -1:
    print("Game not found")

This should be as minimal as it gets while also working, some other strings are needed, for instance upper and lower for games with upper and lower case to be properly read, but for the question it will suffice, to the point, I do not know what to write in the (Uncertain) line of the code to make the script read the name and the appid thereof.

Thanks for reading and for your help.

Yui
  • 13
  • 4
  • 2
    This is your first question and it is fine in case of that. But please try to brake it down to a [minimal working example](https://stackoverflow.com/help/minimal-reproducible-example). It is unclear what your problem is and what the output of your code is. For example leave the steam-thing out of the code and just provide an example fixed steam-string. This help us to reproduce the problem. – buhtz Dec 27 '20 at 16:28
  • I'm afraid SO is community which helps to resolve [concrete questions](https://stackoverflow.com/help/how-to-ask), and your post does not contain one. Please consider to edit your post specifying exact issue you have encountered, with [expected and actual behaviour.](https://stackoverflow.com/help/minimal-reproducible-example) – validname Dec 27 '20 at 16:31
  • 1
    Is the edit better? It's my first time here so I hope it's good now. – Yui Dec 27 '20 at 16:37

1 Answers1

1

From what I've understood, you're having difficulty in printing items from a dictionary. In your case, you can try doing the following.

game_data = {"appid":000000,"name":"Game_Name"}
print(game_data["appid"], game_data["name"])

For more information on printing dictionary items, you can refer How to use a Python dictionary?

dbridgedev
  • 48
  • 5
  • I see, excuse my ignorance, but how to I make it so it updates to the correct value, as in. game_data['appid'] = (Unknown) I know the position of the first letter of the game, but I do not know how to get the entire name and how to get the appid afterwards, I hope I phrased this correctly. – Yui Dec 27 '20 at 16:43
  • Could you rephrase your question? I'm having some difficulty in understanding what you want to achieve. – dbridgedev Dec 27 '20 at 16:45
  • To find the position of the appid for the game that was inputted and get the entire number, and the entire name of the game to set as variables. And with those strings update the dictionary item, or at least that's what I'm thinking might work. – Yui Dec 27 '20 at 16:48