Created
August 27, 2011 22:21
-
-
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
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
#!/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