Example #1
0
# articles aqcuisition process
article_stored = 0
if len(urls_article_list) == 0:
    print "No new article to download"
for article_url in urls_article_list:
    try:
        webpage = req.give_page_content(article_url)
        article_content = lemonde.get_article_text(webpage)
        article_category = lemonde.get_article_category(webpage)
        db.insert_data(table_name, 'Le Monde',article_url, article_content, article_category)
        article_stored += 1
        print "Article stored : ", article_stored
    except Exception as e:
        print "Error in : ", article_url
        print "ERROR : ", e

print "There are currently", len(stored_url_list) + article_stored, "articles stored in the database."

# Display data from database

# db.cursor.execute("SELECT Url FROM ARTICLE WHERE Source='Le Monde'")

# for each in db.cursor.fetchall():
#     print
#     print
#     print each
#     print

# Post processing
db.kill_connect()