示例#1
0
文件: app.py 项目: skao21/uncdatacamp
def index():

    mars = mongo.db.mars.find_one()
    if mars == None:
        # loading  collection mar if nothing in the data base mars_db
        mongo.db.mars.update({}, scrape_mars.scrape_all_sites(), upsert=True)
        time.sleep(1)
        mars = mongo.db.mars.find_one()

    return render_template("index.html", mars=mars)
示例#2
0
def scrape_all_sites():

    #####mars_news_data = mongo.db.mars_data
    mars_news_data = scrape_mars.scrape_all_sites()

    # Insert mars_news_data into database collection mars_data
    mongo.db.mars_data.update({}, mars_news_data, upsert=True)

    # Redirect back to Landing Page
    ###return redirect("http://localhost:5000/", code=302)
    return redirect("/", code=302)
示例#3
0
def scrape_all_sites():

    print("We are in scrape")

    #####mars_news_data = mongo.db.mars_data
    mars_news_data = scrape_mars.scrape_all_sites()

    # Insert mars_news_data into database collection mars_data
    mongo.db.mars_data.update({}, mars_news_data, upsert=True)
    #for MongoClient # db.mars_data.update({}, mars_news_data, upsert=True)

    # Redirect back to Landing Page
    return redirect("/", code=302)
示例#4
0
文件: app.py 项目: skao21/uncdatacamp
def scrape():
    mars = mongo.db.mars
    data = scrape_mars.scrape_all_sites()
    mars.update({}, data, upsert=True)

    return redirect("http://localhost:5000/", code=302)