Skip to content

Instantly share code, notes, and snippets.

Created Jan 20, 2015
What would you like to do?
A nightfall/heroic strike information scraper
from functools import partial
import requests
import bs4
template = "%(strike)s. Modifiers: %(mods)s"
event_url = ''
def get_mods(soup, index):
mod_list ='ul')[index]
modifiers = [li.text for li in'li')]
modifiers = ', '.join(modifiers)
return modifiers
def get_soup(event_url):
response = requests.get(event_url)
html = response.text
soup = bs4.BeautifulSoup(response.text)
return soup
def strike_title(soup):
title ='')[-1].text
return title
nightfall_mods = partial(get_mods, index=9)
heroic_mods = partial(get_mods, index=10)
def nightfall_info(soup):
return template % {'strike': strike_title(soup),
'mods': nightfall_mods(soup)}
def heroic_info(soup):
return template % {'strike': strike_title(soup),
'mods': heroic_mods(soup)}
if __name__ == '__main__':
soup = get_soup(event_url)
print nightfall_info(soup)
print heroic_info(soup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment