Last active
January 18, 2024 10:09
-
-
Save RaidFourms/ede84180167d19a817e2223e66d09942 to your computer and use it in GitHub Desktop.
War Thunder scraper
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
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 #### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great job!