Skip to content

Instantly share code, notes, and snippets.

@pkpp1233
Created December 4, 2014 20:36
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 pkpp1233/a749f46a32af317ac44d to your computer and use it in GitHub Desktop.
Save pkpp1233/a749f46a32af317ac44d to your computer and use it in GitHub Desktop.
scraper block
import blockspring
import urllib
from bs4 import BeautifulSoup
def block(request, response):
sport = request.params["sport"]
html = urllib.urlopen("http://www.espn.com/" + sport).read()
headlines = [headline.get_text() for headline in BeautifulSoup(html).find(class_="headlines").find_all('li')]
response.addOutput("text", headlines)
response.end()
blockspring.define(block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment