def addNewsArticle(companyModel,newsSourceModel,url): tree = html.fromstring(requests.get(url).text) # Need the article title title = tree.xpath('//h1/text()')[0] # Need the text of the article textElements = tree.xpath("//*[@id='articleText']//*/text()") text = "" for t in textElements: text += t # Need the date field dateText = tree.xpath("//div[@id='articleInfo']//span[@class='timestamp']/text()")[0] date = datetime.datetime.strptime(dateText[:-4], "%a %b %d, %Y %I:%M%p").date() News.create( company=companyModel, newsSource=newsSourceModel, title=title, text=text, url=url, date = date ) print "Added: "+title