title: python and beautifulsoup scraping football
body: <p>was looking at a football scraping python program and found this on stackoverflow that suits my needs,
  <a href="https://stackoverflow.com/questions/21501949/python-beautifulsoup4-website-parsing/41664321#41664321">Python Beautifulsoup4 website parsing</a></p>
  
  <p>what I am trying to do is modify it to only return scores for a particular date or set of dates, just cannot work out how to do this. But this just returns every result for every date .
  Thx,
  Mal</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import urllib2
  import csv
  
  url = 'http://www.bbc.co.uk/sport/football/fa-cup/results'
  page = urllib2.urlopen(url).read()
  soup = BeautifulSoup(page)
  
  league =  'FA'
  
  for games in soup.find_all('table', class_='table-stats'):
      played_tag = games.find('caption')
      played = played_tag and ''.join(played_tag.stripped_strings)
      print played
  
      for match in soup.find_all('td', class_='match-details'):
          home_tag = match.find('span', class_='team-home')
          home = home_tag and ''.join(home_tag.stripped_strings)
          score_tag = match.find('span', class_='score')
          score = score_tag and ''.join(score_tag.stripped_strings)
          away_tag = match.find('span', class_='team-away')
          away = away_tag and ''.join(away_tag.stripped_strings)
  
          if ( score.split('-')[0] &gt; score.rsplit('-')[1] ):
              home_win = 1
          else:
              home_win = 0
  
          if (score.rsplit('-')[1] &gt; score.split('-')[0] ):
              away_win = 1
          else:
              away_win = 0
  
  
          if home and score and away:
              print league,',',home,',',home_win,',',score
              print league,',',away,',',away_win,',',score
  </code></pre>