Skip to content

Instantly share code, notes, and snippets.

@nebularg
Created February 17, 2018 14:24
Show Gist options
  • Save nebularg/493877d1b947be8949bfeb78c2f4517f to your computer and use it in GitHub Desktop.
Save nebularg/493877d1b947be8949bfeb78c2f4517f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import requests
from bs4 import BeautifulSoup
def parse_page(locale, page):
url = 'http://%s.wowhead.com/%s' % (locale, page)
if locale == 'www':
locale = 'en'
try:
response = requests.get(url)
if 'notFound' in response.url:
print('[%s] No result' % locale)
else:
soup = BeautifulSoup(response.content, 'html.parser')
text = soup.find_all('h1', class_='heading-size-1')[0].get_text()
print('[%s] %s' % (locale, text))
except:
print('[%s] Error!' % locale)
def go(page):
locales = [ 'www', 'de', 'es', 'fr', 'it', 'pt', 'ru', 'ko', 'cn' ]
for locale in locales:
parse_page(locale, page)
if len(sys.argv) != 2:
print("usage: ./%s [spell|item|npc]=id" % sys.argv[0])
sys.exit()
go(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment