Esempio n. 1
0
def scrape():

    # Run the scrape function
    mars_data = scrapemars.scrape()

    # Update the Mongo database using update and upsert=True
    mongo.db.mongomars.update({}, mars_data, upsert=True)

    # Redirect back to home page
    return redirect("/")
def go_scrape():
    # scrape the data
    # if more than 3 errors occur the previous data will be retained and redisplayed
    mars_dict = scrape()

    if mars_dict["error_count"] < 4:
        #use new data if less than 3 errors else retain previous data
        # disguard old data in db
        mongo.db.mars_data.drop()
        collection = mongo.db.mars_data
        # Insert into database
        collection.insert_one({"entry": mars_dict})
    else:
        print("ERROR LIMIT REACHED previous data retained")
    # Redirect back to home page
    return redirect("/", code=302)
Esempio n. 3
0
def scrape():

    # Run the scrape function
    latest_news = scrapemars.scrape()

    # Update the Mongo database using update and upsert=True
    mongo.db.lastest.update({}, latest_news , upsert=True)


    Featured_address= scrapemars.scrape1()
    mongo.db.Featured.update({}, Featured_address,  upsert=True)

    weather_info = scrapemars.scrape2()
    mongo.db.Weather.update({}, weather_info,  upsert=True)

    Hemisphere_address= scrapemars.scrape3()
    mongo.db.Hemisphere.update({}, Hemisphere_address,  upsert=True)


    # Redirect back to home page
    return redirect("/")
Esempio n. 4
0
def scraper():
    mars = mongo.db.listings
    mars_data = scrapemars.scrape()
    mars.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
Esempio n. 5
0
def scraper():
    mars_data = scrapemars.scrape()
    mongo.db.collection.update({}, mars_data, upsert=True)
    return redirect("/")