3 changed files with 61 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||
This are basic examples how to get the wallet balance |
|||
|
|||
wallet_steamclient.py |
|||
--------------------- |
|||
|
|||
This first script is very basic. |
|||
Prompts for loging, handles code prompts and prints wallet balalnce. |
|||
Since there is no handling for the result of ``cli_login`` during |
|||
this might break in certain situations like when Steam is down. |
|||
|
|||
wallet_webauth.py |
|||
----------------- |
|||
|
|||
This script is a little bit more complicated and instead logs in to the steam website. |
|||
Once logged in to the website, it requests a single page and finds the balance in the source code. |
|||
There is basic structure to handle code prompts. |
|||
Entering username, password or codes wrong will result in an error as there is na ologic to handle that. |
@ -0,0 +1,15 @@ |
|||
from steam.client import SteamClient, EMsg |
|||
from steam.enums import EResult, ECurrencyCode |
|||
|
|||
client = SteamClient() |
|||
|
|||
@client.on(EMsg.ClientWalletInfoUpdate) |
|||
def print_balance(msg): |
|||
bucks, cents = divmod(msg.body.balance64, 100) |
|||
print("Current balance is {:d}.{:02d} {:s}".format(bucks, |
|||
cents, |
|||
ECurrencyCode(msg.body.currency).name |
|||
)) |
|||
|
|||
client.cli_login() |
|||
client.disconnect() |
@ -0,0 +1,29 @@ |
|||
import re |
|||
from getpass import getpass |
|||
import steam.webauth as wa |
|||
|
|||
try: |
|||
user_input = raw_input |
|||
except NameError: |
|||
user_input = input |
|||
|
|||
username = user_input("Username: ") |
|||
password = getpass("Password: ") |
|||
|
|||
webclient = wa.WebAuth(username, password) |
|||
|
|||
try: |
|||
webclient.login() |
|||
except wa.CaptchaRequired: |
|||
print("Captcha:" + webclient.captcha_url) |
|||
webclient.login(captcha=user_input("Captcha code: ")) |
|||
except wa.EmailCodeRequired: |
|||
webclient.login(email_code=user_input("Email code: ")) |
|||
except wa.TwoFactorCodeRequired: |
|||
webclient.login(twofactor_code=user_input("2FA code: ")) |
|||
|
|||
if webclient.complete: |
|||
resp = webclient.session.get('https://store.steampowered.com/account/store_transactions/') |
|||
resp.raise_for_status() |
|||
balance = re.search(r'store_transactions/">(?P<balance>.*?)</a>', resp.text).group('balance') |
|||
print("Current balance: %s" % balance) |
Loading…
Reference in new issue