├── README.md ├── bad.webp ├── good.webp └── standoff.py /README.md: -------------------------------------------------------------------------------- 1 | # standoff-2-API 2 | API for standoff 2 3 | # install playwright 4 | ```python 5 | pip install pytest-playwright 6 | playwright install 7 | ``` 8 | # how to use 9 | ```python 10 | standoff.account('id') #will return the name and link to the avatar 11 | standoff.avatar('url') #will create in the same directory "gg.webp" with the image of the avatar if there is no avatar, then the file cannot be opened 12 | ``` 13 | # example 14 | ```python 15 | import standoff 16 | _ = standoff.account(42073869) 17 | print(_) 18 | #output 19 | #('kexswt_', 'https://avatars-19e92.kxcdn.com/48c416cd-3fdc-47fe-b302-bcac3f78dd00') 20 | standoff.avatar(pr[1]) 21 | #and create image.webp 22 | ``` 23 | # have an avatar 24 | ![alt text](good.webp "") 25 | # no avatar 26 | ![alt text](bad.webp "") 27 | -------------------------------------------------------------------------------- /bad.webp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 403 Forbidden 10 | 11 | 52 | 53 | 54 | 55 |
56 |

403 Forbidden

57 |

The access to the resource has been denied.

58 |
59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /good.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/no-comm/standoff-2-API/5942edfcf37656b393057187636b54adcbe54dc6/good.webp -------------------------------------------------------------------------------- /standoff.py: -------------------------------------------------------------------------------- 1 | from playwright.sync_api import Playwright, sync_playwright, expect 2 | import requests 3 | 4 | def run(playwright: Playwright, id: str) -> None: 5 | browser = playwright.chromium.launch(headless=True) 6 | context = browser.new_context() 7 | page = context.new_page() 8 | page.goto("https://store.standoff2.com/") 9 | page.get_by_placeholder("ID").click() 10 | page.get_by_placeholder("ID").fill(id) 11 | page.query_selector('//*[@id="boom"]/div/div/div/div[3]/div[2]/button').click() 12 | url = page.locator("img").nth(1).get_attribute("src") 13 | name = page.query_selector('//*[@id="boom"]/div/div/div/div[4]/div/div[2]/div[2]').text_content() 14 | context.close() 15 | browser.close() 16 | return [name, url] 17 | 18 | def account(id: str) -> list["name", "url"]: 19 | with sync_playwright() as playwright: 20 | return run(playwright, id) 21 | 22 | def avatar(url: str): 23 | f=open(r'image.webp', "wb") 24 | ufr = requests.get(url) 25 | f.write(ufr.content) 26 | f.close() 27 | --------------------------------------------------------------------------------