def retrieve_all_articles(self):
"""retrieves all articles. useful for crawling or making media wiki api requests
@return a list of dictionaries holding the following keys:
'id': the id of the retrieved article
'rev_id': the revision id of the retrieved article
'title': the title of the retrieved article
"""
articles = []
try:
#self._cursor.execute('SELECT * FROM articles WHERE RAND()<=0.0006 limit 1000;')
#self._cursor.execute('SELECT * FROM articles limit 1000;')
self._cursor.execute('SELECT * FROM articles;')
result = self._cursor.fetchall()
for row in result:
article = {}
article['id'] = row[0]
article['rev_id'] = row[1]
article['title'] = row[2]
articles.append(article)
except MySQLdb.Error, e:
logging.error('error retrieving 1000 random articles %s (%d)' % (e.args[1], e.args[0]))
return articles
评论列表
文章目录