Skip to content

Instantly share code, notes, and snippets.

@BrianFehrle
Created August 27, 2011 22:21
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 BrianFehrle/1175937 to your computer and use it in GitHub Desktop.
Save BrianFehrle/1175937 to your computer and use it in GitHub Desktop.
Retrieves the name of a spell using the spell id from wowhead.com
#!/usr/bin/python
import lxml.html
from string import replace
# define a list of mount spell id's
mount_id_lst = ['61470','13819']
# loop through each id
for mount_id in mount_id_lst:
# Create the url for wowhead for this spell id
url = "http://www.wowhead.com/spell=%s" % mount_id
# Retrive and parse the xml into t
t = lxml.html.parse(url)
# Extract the title
name = t.find(".//title").text
# Split the title on ' - ', and grab the first element (removes the " - Spell - World of Warcraft" from the title)
name = name.split(' - ')[0]
# Print the result
print "For mount spell id [%s] the name is [%s]" % (mount_id, name)
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment