Skip to content

Instantly share code, notes, and snippets.

@ZachOrr
Last active December 18, 2015 09:08
Show Gist options
  • Save ZachOrr/5758749 to your computer and use it in GitHub Desktop.
Save ZachOrr/5758749 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import urllib2
import re
def get_sponsors(team_number):
url = re.findall('window.location = "(.*?)";', BeautifulSoup(urllib2.urlopen("http://frclinks.frclinks.com/t/{0}".format(str(team_number)))).find_all('script')[2].get_text().strip())[0]
return BeautifulSoup(urllib2.urlopen(url)).find_all("div", {"class":"team-name"})[0].get_text()
def get_sponsors_long(team_number):
url = "http://frclinks.frclinks.com/t/{0}".format(str(team_number))
html = urllib2.urlopen(url)
soup = BeautifulSoup(html)
redirect_script = soup.find_all('script')[2].get_text().strip()
redirect_url = re.findall('window.location = "(.*?)";', redirect_script)[0]
return BeautifulSoup(urllib2.urlopen(redirect_url)).find_all("div", {"class":"team-name"})[0].get_text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment