Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import json
- urls = [
- "http://download.gameforge.com/metin2_20171214/clients/{country_url}/Metin2_{timestamp}_softonic.exe",
- "http://download.gameforge.com/metin2_20171214/clients/{country_url}/Metin2_{country_file}_{timestamp}.exe",
- ]
- country_codes = [
- "us", "en", "de", "fr", "ro", "it", "tr", "pl", "es", "pt", "dk",
- "nl", "cz", "hu", "gr", "ru", "ae",
- ]
- timestamps = [
- "20081204",
- "20111216",
- "20100528",
- # "20080811",
- # "20090526",
- # "20091214",
- # "20100421",
- ]
- def discover_timestamp(timestamp):
- hits = []
- possible_urls = []
- for country in country_codes:
- for url in urls:
- normal_url = url.format(timestamp=timestamp, country_url=country, country_file=country)
- upper_url = url.format(timestamp=timestamp, country_url=country, country_file=country.upper())
- possible_urls.append({
- 'url': normal_url,
- 'country': country,
- })
- if normal_url != upper_url:
- possible_urls.append({
- 'url': upper_url,
- 'country': country,
- })
- for url in possible_urls:
- try:
- status = urllib.request.urlopen(url['url']).getcode()
- if status == 200:
- hits.append(url)
- else:
- print(status)
- except Exception:
- pass
- print("Valid URLs found for timestamp {}: {}".format(timestamp, len(hits)))
- return hits
- def get_links():
- download_urls = []
- for timestamp in timestamps:
- print("Checking timestamp {}...".format(timestamp))
- download_urls += discover_timestamp(timestamp)
- return download_urls
- links = get_links()
- with open("links.json", "w") as file:
- json.dump(links, file)
- print("Done.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement