def createSpreadsheet():
wb = xlwt.Workbook()
sheet = wb.add_sheet("Google Alerts")
style = xlwt.easyxf('font: bold 1')
sheet.write(0, 3, 'Headline', style)
sheet.write(0, 1, 'Company', style)
sheet.write(0, 4, 'URL', style)
sheet.write(0, 0, 'Date', style)
cur_row = 1
for url in LA_HONDA_ALERTS_URLS:
print 'Processing google alerts for ' + LA_HONDA_ALERTS_URLS[url] + '...'
r = requests.get(url)
xml = r.text
soup = BeautifulSoup(xml)
for title, link, date in zip(soup.findAll('title')[1:], soup.findAll('link')[1:], soup.findAll('published')):
title = cleanTitle(title)
link = cleanLink(link)
date = cleanDate(date)
writeToSheet(sheet, title, LA_HONDA_ALERTS_URLS[url], link, date, cur_row)
cur_row = cur_row + 1
processSheet(sheet)
savewb(wb)
评论列表
文章目录