-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c808104
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
import urllib.request | ||
|
||
# Fill in your own values for the key and steamid variables | ||
key = '1234567890ABCDEF1234567890ABCDEF' # Your Steam Web API key, get it from: https://steamcommunity.com/dev/apikey | ||
steamid = '76561198092541763' # The Steam ID to get the friends list from, find yours from a website like https://steamid.io/ | ||
|
||
# Construct the URL with the key and steamid variables | ||
url = 'https://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=' + key + '&steamid=' + steamid + '&relationship=friend' | ||
|
||
# Fetch the JSON data from the URL | ||
response = urllib.request.urlopen(url) | ||
json_data = json.loads(response.read()) | ||
|
||
# Extract the steam IDs from the JSON | ||
steam_ids = [friend['steamid'] for friend in json_data['friendslist']['friends']] | ||
|
||
# Concatenate the steam IDs into a comma-separated string | ||
steam_ids_str = ','.join(steam_ids) | ||
|
||
# Output the steam IDs string | ||
print(steam_ids_str) | ||
|
||
# Write the result to the friends.txt file | ||
with open('friends.txt', 'w') as f: | ||
f.write(steam_ids_str) |