title: Scraping headlines from Yahoo Finance using Python
body: <p>I am using beautiful soup to extract headlines from this page <a href="http://in.finance.yahoo.com/q?s=AAPL" rel="nofollow">http://in.finance.yahoo.com/q?s=AAPL</a> but I need headlines for past 3 months i.e from 10 Dec 2013 to 10 March 2014. But I am able to extract only the headlines that are their on this specific page. How to extract the required headlines for any specific company?</p>
  
  <p>Code:</p>
  
  <pre><code>url = 'http://in.finance.yahoo.com/q?s=AAPL'
  data = urllib2.urlopen(url)
  soup = BeautifulSoup(data)
  
  divs = soup.find('div',attrs={'id':'yfi_headlines'})
  div = divs.find('div',attrs={'class':'bd'})
  ul = div.find('ul')
  lis = ul.findAll('li')
  hls = []
  for li in lis:
      headlines = li.find('a').contents[0]
      print headlines
  </code></pre>