コード例 #1
0
 def fetchArticleTest(self):
     articles = []
     FetchArticle.fetch("\"AT&T Inc\"", "http://www.bloomberg.com/news/2012-11-29/cox-considers-buying-business-services-to-step-up-at-t-challenge.html", 1,articles,1)
     if not articles:
         self.fail("Article contained keyword but was not saved")
     FetchArticle.fetch("\"AT&T Inc\"", "http://www.bloomberg.com/news/2012-11-29/cox-considers-buying-business-services-to-step-up-at-t-challenge.html", 1,articles,1)
     if articles:
         self.fail("Article did not contain keyword but was saved")
コード例 #2
0
 def getArticlesFromTSV(self, fileName):
     fileName = os.path.join(os.path.dirname(__file__), "../", fileName)
     tempArticles = []
     articles = []
     with open(fileName, 'r', encoding='utf-8') as csvFile:
         defaultParametersFileReader = csv.reader(csvFile, delimiter='\t')
         for row in defaultParametersFileReader:
             article = Article.Article("", row[0], -1,row[2])
             FetchArticle.fetch("\"" + row[3] + "\"", article.URL, article.rank, tempArticles, 0)
             article.paragraphs = [tempArticles[0].text]
             tempArticles = []
             articles.append(article)
         csvFile.close()
         return articles