Skip to content

Instantly share code, notes, and snippets.

@RaidFourms
Last active January 18, 2024 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaidFourms/ede84180167d19a817e2223e66d09942 to your computer and use it in GitHub Desktop.
Save RaidFourms/ede84180167d19a817e2223e66d09942 to your computer and use it in GitHub Desktop.
War Thunder scraper
import requests
import string
def getstrings(length, prefix=""):
if length == 0:
return [prefix]
result = []
for s in string.ascii_lowercase:
result.extend(getstrings(length - 1, prefix + s))
return result
def main():
start = input("Where to start. Press enter to skip: ")
if start == "":
start = "aaaa" #change this too
found = not start
# URL template
url_template = "https://companion-app.warthunder.com/call/?nick={}&count=999&classname=eaw_Contacts&method=jzx_findUsersByNickPrefix&v=9"
with requests.Session() as session:
for s in getstrings(4): #### Change this, ln 17 and 38 for different lengths
if s != start and start and not found:
continue
elif s == start and not found:
found = True
url = url_template.format(s)
response = session.get(url)
with open(f"{s}.txt", "w") as f:
f.write(response.text)
print(s)
if s == "zzzz": #aaaand this
exit(0)
if __name__ == "__main__":
main()
#### Use JQ to combine JSONs ####
@axiangcoding
Copy link

Great job!

@RaidFourms
Copy link
Author

Great job!

No 💀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment