コード例 #1
0
def scrape():
    # mars news
    mars_news_junk = scrape_mars.mars_news()
    mars_dict["mn_title"] = mars_news_junk[0]
    mars_dict["mn_para"] = mars_news_junk[1]
    # featured image
    mars_featured_image_link = scrape_mars.mars_feat_image()
    mars_dict["mfi"] = mars_featured_image_link
    # mars weather
    mars_latest_weather = scrape_mars.mars_weather()
    mars_dict["mw"] = mars_latest_weather
    # mars hemispheres
    # hemi 1
    mars_hemi1_list = scrape_mars.mars_hemi1()
    mars_dict["mh1_title"] = mars_hemi1_list[0]
    mars_dict["mh1_link"] = mars_hemi1_list[1]
    # hemi 2
    mars_hemi2_list = scrape_mars.mars_hemi2()
    mars_dict["mh2_title"] = mars_hemi2_list[0]
    mars_dict["mh2_link"] = mars_hemi2_list[1]
    # hemi 3
    mars_hemi3_list = scrape_mars.mars_hemi3()
    mars_dict["mh3_title"] = mars_hemi3_list[0]
    mars_dict["mh3_link"] = mars_hemi3_list[1]
    # hemi4
    mars_hemi4_list = scrape_mars.mars_hemi4()
    mars_dict["mh4_title"] = mars_hemi4_list[0]
    mars_dict["mh4_link"] = mars_hemi4_list[1]

    # insert the updated dictionary into Mongo
    # Insert the document into the database
    collection.insert_one(mars_dict)

    return redirect("http://localhost:5000/", code=302)
コード例 #2
0
def scraper():

    db.table.drop()
    db.weather.drop()
    db.hemisphere.drop()
    db.news.drop()
    db.images.drop()

    table_data = scrape_mars.mars_facts_table()
    weather_data = scrape_mars.mars_weather()
    hemisphere_data = scrape_mars.mars_hemisphere()
    news_data = scrape_mars.mars_nasa_lastest_news()
    images_data = scrape_mars.mars_images()

    print(table_data)
    print(weather_data)
    print(hemisphere_data)
    print(news_data)
    print(images_data)

    db.table.insert_one(table_data)
    db.weather.insert_one(weather_data)
    db.hemisphere.insert_many(hemisphere_data)
    db.news.insert_one(news_data)
    db.images.insert_one(images_data)

    return redirect("/", code=302)
コード例 #3
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("/")
コード例 #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)
コード例 #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)
コード例 #6
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("/")
コード例 #7
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("/")
コード例 #8
0
ファイル: app.py プロジェクト: txstu09/marsmission
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)
コード例 #9
0
ファイル: app.py プロジェクト: tesfanesh/mission_to_mars1
def scrape():

    mars_info = mongo.db.mars_info

    #Return scrape function
    mars_data = scrape_mars.mars_news()
    mars_data = scrape_mars.jpl_mars_space()
    mars_data = scrape_mars.mars_weather()
    mars_data = scrape_mars.mars_hemi()
    mars_data = scrape_mars.mars_df()

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

    # Redirect back to home page
    return redirect("/")
コード例 #10
0
def scrape():

    # Run scraped functions
    news = scrape_mars.mars_news()
    featured_image = scrape_mars.JPL_image()
    mars_weather = scrape_mars.mars_weather()
    table = scrape_mars.mars_fact()

    dynamic_dic = {
        "news_title": news.title,
        "news_p": news.news,
        "featured_image": featured_image,
        "weather": mars_weather,
        "facts": table
    }

    # Insert into database
    collection1.insert_one(dynamic_dic)

    # Redirect back to home page
    return redirect("http://localhost:5000/", code=302)
コード例 #11
0
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("/")
コード例 #12
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("/")
コード例 #13
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)
コード例 #14
0
app = Flask(__name__)

conn = 'mongodb://*****:*****@app.route("/")
def index():

    table = db.table.find_one()