| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- import json
- import sys
- from pathlib import Path
- import requests
- API = "http://localhost:5000"
- MAFILE = r"c:\Users\Administrator\Desktop\tsi19338.maFile"
- MARKET = "https://steamcommunity.com/market/listings/730/G180E208A023004"
- OUT = Path(r"d:\code\steam\tljb\_tmp_session.json")
- def main() -> int:
- r = requests.post(
- f"{API}/login",
- json={
- "Username": "tsi19338",
- "Password": "ayx71486",
- "MaFilePath": MAFILE,
- },
- timeout=90,
- )
- print("login", r.status_code)
- r.raise_for_status()
- d = r.json()
- sess = d["session"]
- cookies = {c["name"]: c["value"] for c in d.get("cookies") or []}
- sls = cookies.get("steamLoginSecure") or f"{sess['steamId']}%7C%7C{sess['accessToken']}"
- sid = cookies.get("sessionid") or sess.get("sessionId")
- print("steamId", sess.get("steamId"), "sessionId", sid)
- wr = requests.get(
- "https://store.steampowered.com/api/getfundwalletinfo/?cc=us&l=english",
- headers={"Cookie": f"steamLoginSecure={sls}"},
- timeout=20,
- )
- print("wallet_http", wr.status_code, wr.text[:400])
- url = (
- MARKET
- + "/render/?query=&start=0&count=10&country=US&language=schinese¤cy=1"
- )
- cookie = f"timezoneOffset=28800,0; sessionid={sid}; steamLoginSecure={sls}; bMarketOptOut=1"
- rr = requests.get(
- url,
- headers={"User-Agent": "Mozilla/5.0", "Cookie": cookie, "Referer": MARKET},
- timeout=30,
- )
- print("render", rr.status_code)
- page = rr.json()
- info = page.get("listinginfo") or {}
- print("listing_count", len(info))
- rows = []
- for lid, L in info.items():
- sub = int(L.get("converted_price") or 0)
- sf = int(L.get("converted_steam_fee") or 0)
- pf = int(L.get("converted_publisher_fee") or 0)
- rows.append((str(lid), sub, sf, pf, sub + sf + pf))
- rows.sort(key=lambda x: x[4])
- print(json.dumps(rows[:5], indent=2, ensure_ascii=False))
- OUT.write_text(
- json.dumps(
- {
- "session": sess,
- "steamLoginSecure": sls,
- "sessionId": sid,
- "mafile": MAFILE,
- "cheapest": rows[0] if rows else None,
- "market": MARKET,
- },
- ensure_ascii=False,
- indent=2,
- ),
- encoding="utf-8",
- )
- print("saved", OUT)
- return 0
- if __name__ == "__main__":
- try:
- sys.stdout.reconfigure(encoding="utf-8")
- except Exception:
- pass
- raise SystemExit(main())
|