Skip to content

Instantly share code, notes, and snippets.

@l34marr
Created September 25, 2013 02:21
Show Gist options
  • Save l34marr/6694394 to your computer and use it in GitHub Desktop.
Save l34marr/6694394 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
r = requests.get("http://www.nasdaq.com/symbol/f/dividend-history")
data = r.content
soup = BeautifulSoup(data)
for i in range(1,31):
id_exdate = "#quotes_content_left_dividendhistoryGrid_exdate_"+str(i)
id_cash = "#quotes_content_left_dividendhistoryGrid_CashAmount_"+str(i)
id_decl = "#quotes_content_left_dividendhistoryGrid_DeclDate_"+str(i)
id_rec = "#quotes_content_left_dividendhistoryGrid_RecDate_"+str(i)
id_pay = "#quotes_content_left_dividendhistoryGrid_PayDate_"+str(i)
print soup.select(id_exdate)[0].string+', '+soup.select(id_cash)[0].string+', '+soup.select(id_decl)[0].string+', '+soup.select(id_rec)[0].string+', '+soup.select(id_pay)[0].string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment