Skip to content

Instantly share code, notes, and snippets.

@einstein95
Created May 14, 2016 20:23
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 einstein95/ff501a43923455410d0b46b81b4cdc15 to your computer and use it in GitHub Desktop.
Save einstein95/ff501a43923455410d0b46b81b4cdc15 to your computer and use it in GitHub Desktop.
import re
import requests
import time
from bs4 import BeautifulSoup
counts = ['JP', 'US', 'GB', 'AU', 'FR', 'DE', 'TW', 'KR', 'ES', 'AI', 'AG', 'AR', 'AW', 'BS', 'BB', 'BZ', 'BO', 'BR', 'VG', 'CA', 'KY', 'CL', 'CO', 'CR', 'DM', 'DO', 'EC', 'SV', 'GF', 'GD', 'GP', 'GT', 'GY', 'HT', 'HN', 'JM', 'MQ', 'MX', 'MS', 'AN', 'NI', 'PA', 'PY', 'PE', 'KN', 'LC', 'VC', 'SR', 'TT', 'TC', 'UY', 'VI', 'VE', 'AT', 'BE', 'CZ', 'DK', 'FI', 'GR', 'IE', 'IT', 'LU', 'ME', 'NL', 'NZ', 'NO', 'PL', 'PT', 'RU', 'ZA', 'SE', 'CH', 'TR', 'HK', 'SG', 'MY', 'AE', 'SA', 'BM']
open('titles.txt', 'w')
for d in [(4, 0), (5, 1)]:
for i in range(0xFFFFF):
page = requests.get('https://ninja.ctr.shop.nintendo.net/ninja/ws/titles/id_pair?title_id[]=000{:}0000{:}{:05x}00'.format(d[0], d[1], i), cert=('ClCertA.pem'), verify=False).text
nsid = re.findall('<ns_uid>(.+?)</ns_uid>', page)
if not nsid:
continue
for c in counts:
try:
page = requests.get('https://samurai.ctr.shop.nintendo.net/samurai/ws/{:}/title/{:}?shop_id=2'.format(c, nsid[0]), verify=False)
page.encoding = 'utf-8'
page = page.text
except requests.exceptions.ConnectionError as e:
time.sleep(4)
page = requests.get('https://samurai.ctr.shop.nintendo.net/samurai/ws/{:}/title/{:}?shop_id=2'.format(c, nsid[0]), verify=False)
page.encoding = 'utf-8'
page = page.text
if not re.findall('<code>.+?</code>', page):
soup = BeautifulSoup(page, "lxml")
print('000{:}0000{:}{:05x}00'.format(d[0], d[1], i), c, soup.title['public'], soup.find_all('name')[0].string)
with open('titles.txt', 'a') as log:
log.write('\t'.join(['000{:}0000{:}{:05x}00'.format(d[0], d[1], i), c, soup.title['public'], soup.find_all('name')[0].string])+'\n')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment