Download premiership fixtures from BBC


/ Published in: Python
Save to your folder(s)

Needs the BeautifulSoup module.


Copy this code and paste it in your HTML
  1. import os
  2. import urllib2
  3. import sys
  4. from BeautifulSoup import BeautifulSoup
  5.  
  6. bbcurl = "http://news.bbc.co.uk/sport2/hi/football/eng_prem/fixtures/default.stm"
  7.  
  8. doc = urllib2.urlopen(bbcurl).read()
  9. soup = BeautifulSoup(doc)
  10. mvbs = soup.findAll('div', { 'class' : 'mvb' })
  11.  
  12. for mvb in mvbs:
  13. if mvb.b:
  14. date = mvb.b.contents
  15. else:
  16. mvb = mvb.findNext('span')
  17. home = mvb.a.contents
  18. mvb = mvb.findNext('span')
  19. away = str(mvb.a.contents)
  20.  
  21. print "DATE %s %s vs %s" % (date, home, away)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.