Ejemplo n.º 1
0
def scrape():     
    mars_info=scrape_mars.mars_news_scrape()
    mars_info=scrape_mars.img_scrape()
    mars_info=scrape_mars.mars_weather()
    mars_info=scrape_mars.mars_facts()
    mars_info=scrape_mars.mars_hem()
    mongo.db.mars_db.update({},mars_info,upsert=True)
    return redirect("/")
Ejemplo n.º 2
0
def scrape():
    mars_information = mongo.db.mars_information
    mars_data = scrape_mars.scrape_news()
    mars_data = scrape_mars.featured_image()
    mars_data = scrape_mars.weather()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hemisphere()
    mars_information.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
Ejemplo n.º 3
0
def scrape():

    mars_news = mongo.db.mars_news
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.featured_image()
    mars_data = scrape_mars.mars_facts()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/")
Ejemplo n.º 4
0
def scrape():
    mars_scrape = scrape_mars.scrape()
    mars_info = scrape_mars.img_scrape()
    mars_info = scrape_mars.mars_weather()
    mars_info = scrape_mars.mars_facts()
    mars_info = scrape_mars.mars_hem()
    print(mars_scrape)
    mongo.db.mars.update({}, mars_scrape, upsert=True)
    return redirect("http://localhost:5000/", code=302)
Ejemplo n.º 5
0
def scrape():
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.mars_image()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_weather()
    mars_data = scrape_mars.mars_hemispheres()
    mongo.db.mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
Ejemplo n.º 6
0
def scrape():
    mars = mongo.db.mars
    mars_scrape = scrape_mars.news()
    mars_scrape = scrape_mars.nasa_image()
    mars_scrape = scrape_mars.weather()
    mars_scrape = scrape_mars.mars_facts()
    mars_scrape = scrape_mars.hemispheres()

    mars.update({}, mars_scrape, upsert=True)
    return redirect("/", code=302)
Ejemplo n.º 7
0
def scrape():

    # Run scrapped functions
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.mars_image()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("http://localhost:5000/", code=302)
Ejemplo n.º 8
0
def scrape():
    # Create variable from mongo db mars
    mars = mongo.db.mars
    # Call on all def functions from scrape_mars.py
    mars_data = scrape_mars.latest_news()
    mars_data = scrape_mars.featured_image()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hem()
    # Call on updated data
    mars.update({}, mars_data, upsert=True)
    # Using return redirect to index page
    return redirect("/", code=302)
Ejemplo n.º 9
0
def scrape():

    #Run the scrape function
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.mars_image()
    mars_data = scrape_mars.mars_twitter()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
Ejemplo n.º 10
0
def scrape():
    # Run scraped functions
    scrape_data = mongo.db.scrape_data
    mars_data = scrape_mars.scrape_nasa()
    mars_data = scrape_mars.scrape_image()
    mars_data = scrape_mars.scrape_weather()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.hemispheres()
    print(mars_data)
    scrape_data.update({}, mars_data, upsert=True)

    #Redirecting back to home page
    return redirect("/", code=302)
Ejemplo n.º 11
0
def scrape():

    mars = mongo.db.collection

    mars_info = scrape_mars.scrape()
    mars_info = scrape_mars.mars_image()
    # mars_info = scrape_mars.mars_weather()
    mars_info = scrape_mars.mars_facts()
    mars_info = scrape_mars.mars_hemispheres()

    mars.update({}, mars_info, upsert=True)

    return redirect("/")
Ejemplo n.º 12
0
def scraper():

    # scrape_mars.scrape() is a custom function that we've defined in the scrape_mars.py file within this directory
    mars_info
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.featured_image()
    mars_data = scrape_mars.mars_weather()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hemi()
    mars_info.update({},mars_data, upsert=True)
    
    # Use Flask's redirect function to send us to a different route once this task has completed.
    return redirect("/")
Ejemplo n.º 13
0
def scrape():

    # Run the scrape function
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.mars_image()
    mars_data = scrape_mars.mars_weather()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.mars_hemispheres()

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

    # Redirect back to home page
    return redirect("/")
Ejemplo n.º 14
0
def scrape():
    news = scrape_mars.mars_news()
    image = scrape_mars.mars_image()
    weather = scrape_mars.mars_weather()
    facts = scrape_mars.mars_facts()
    hemispheres = scrape_mars.mars_hemispheres()

    db.news.insert_one(news)
    db.image.insert_one(image)
    db.weather.insert_one(weather)
    for fact in facts:
        db.facts.insert_one(fact)
    for hemisphere in hemispheres:
        db.hemispheres.insert_one(hemisphere)
    return redirect("http://localhost:5000/", code=302)
def scrape():

    # Run the scrape function
    ### Convert the dataframe into a dictionary to store in the database.
    mars_dataframe = scrape_mars.mars_facts()
    records = mars_dataframe.to_json(None, orient='records')
    mars_news = scrape_mars.mars_news_title()

    mars_data_dict = {
        "fullresolimage": scrape_mars.background_image(),
        "mars_news_title": mars_news[0],
        "mars_news_content": mars_news[1],
        "mars_weather": scrape_mars.mars_weather(),
        "mars_dataframe": records,
        "mars_hemisphere_images": scrape_mars.mars_hemisphere_images()
    }

    db.collection.insert_one(mars_data_dict)

    # Redirect back to home page
    return redirect("/")
Ejemplo n.º 16
0
def scrape():

    mars = mongo.db.mars

    mars_data = {}

    # Run the scrape function
    print("Start scraping")

    try:
        mars_data['news'] = scrape_mars.news_scrape()
    except Exception as e:
        print("Fail to scrape news")
        raise e

    try:
        mars_data['image'] = scrape_mars.image_scrape()
    except:
        print("Fail to scrape image")

    try:
        mars_data['weather'] = scrape_mars.weather_scrape()
    except:
        print("Fail to scrape weather")

    try:
        mars_data['facts'] = scrape_mars.mars_facts()
    except:
        print("Fail to scrape facts")

    try:
        mars_data['hemi'] = scrape_mars.hemi_scrape()
    except:
        print("Fail to scrape hemi")

    print("End scrape")

    # Update the Mongo database using update and upsert=True
    mars.update({}, mars_data, upsert=True)
    return redirect("/")
Ejemplo n.º 17
0
def scrape():

    # 1.
    # Run the Latest New scrape function:
    Latest_New = scrape_mars.NASA_Mars_News()

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

    # 2.
    # Run the featured image scrape function:
    featured_image = scrape_mars.featured_image()

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

    # 3.
    # Run the weather scrape function:
    mars_weather = scrape_mars.mars_weather()

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

    # 4.
    # Run the facts scrape function:
    mars_facts = scrape_mars.mars_facts()

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

    # 5.
    # Run the hemispheres scrape function:
    mars_hemispheres = scrape_mars.mars_hemispheres()

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

    # Redirect back to home page
    return redirect("/")
Ejemplo n.º 18
0
def scrape():
    news = scrape_mars.mars_news()
    try:
        db.news.insert_many(news)
        print("News Uploaded!")
    except TypeError as e:
        print("Mars News Error" + e)
    #Get featured image
    mars_pic = scrape_mars.mars_image()
    try:
        db.featured.insert_one(mars_pic)
        print("Feature Image Uploaded!")
    except TypeError as e:
        print("Feature Image Error" + e)
    #Get latest weather from Twitter
    weather = scrape_mars.mars_weather()

    try:
        db.weather.insert_one(weather)
        print("Weather Uploaded!")
    # Get mars facts table
    except TypeError as e:
        print("Weather Tweet Error" + e)

    facts = scrape_mars.mars_facts()
    try:
        db.facts.insert_one(facts)
        print("Facts Uploaded!")
        # Get images of mars hemispheres
    except TypeError as e:
        print("Mars Facts Error" + e)

    hems = scrape_mars.mars_hemispheres()
    try:
        db.images.insert_many(hems)
        print("Hemispheres Uploaded!")
    except TypeError as e:
        print("Hemisphere scrape error" + e)
Ejemplo n.º 19
0
def scrape():
    # Scrape for latest Mars news and store in mongo database
    latest_mars_news = scrape_mars.latest_mars_news()
    mongo.db.latestMarsNews.update({}, latest_mars_news, upsert=True)

    # Scrape latest featured image and store in mongo database
    featured_image = scrape_mars.featured_image()
    mongo.db.featuredImage.update({}, featured_image, upsert=True)

    # Scrape latest Mars weather and store in mongo database
    weather = scrape_mars.current_mars_weather()
    mongo.db.marsWeather.update({}, weather, upsert=True)

    # Scrape Mars facts and store in mongo database
    mars_facts = scrape_mars.mars_facts()
    mongo.db.marsFacts.update({}, mars_facts, upsert=True)

    # Scrape Mars hemispheres and store in mongo database
    mars_hemispheres = scrape_mars.mars_hemispheres()
    mongo.db.marsHemispheres.drop()  # Refresh with new collection
    mongo.db.marsHemispheres.insert_many(mars_hemispheres)

    # Redirect back to home page
    return redirect("/")