コード例 #1
0
ファイル: app.py プロジェクト: sisayyt/sisayyt.githab.io
def scrape():
    try:
        mars_news = scrape_mars.scrape_mars_news()
        mars_image = scrape_mars.scrape_mars_image()
        mars_facts = scrape_mars.scrape_mars_facts()
        mars_weather = scrape_mars.scrape_mars_weather()
        data = scrape_mars.scrape_mars_facts()
        mars_hemispheres = scrape_mars.scrape_mars_hemispheres()

        # Create Mission to Mars dictionary, which will be imported into Mongo
        mars_info = {}

        # Dictionary entry from MARS NEWS
        mars_info['news_title'] = mars_news[0]
        mars_info['news_paragraph'] = mars_news[1]
        # Dictionary entry from fetured image created in line 14
        mars_info['featured_image_url'] = mars_image
        # Dictionary entry from Weather twitts
        mars_info['weather_tweet'] = mars_weather
        # Dictionary entry from MARS FACTS
        mars_info['mars_facts'] = data
        mars_info['hiu'] = mars_hemispheres

        db.mars.update({}, mars_info, upsert=True)
        mars_info_data = db.mars.find_one()
    except:
        mars_info_data = db.mars.find_one()

    return render_template("index.html", mars_info=mars_info_data)
コード例 #2
0
def scrape():

    # Scraped functions
    mars_db = mongo.db.mars_info
    scrape_mars.scrape_mars_news()
    scrape_mars.scrape_mars_image()
    scrape_mars.scrape_mars_weather()
    scrape_mars.scrape_mars_facts()
    scrape_mars.scrape_mars_hemispheres()
    # mars_info={'key1':'test'}
    mars_db.update({}, mars_info, upsert=True)
    mongo.db.collection.update({}, mars_data, upsert=True)
コード例 #3
0
def scrappe():
    mars_mongo = mongo.db.mars_info
    mars_info = scrape_mars.scrape_mars_news()
    mars_info = scrape_mars.scrape_mars_facts()
    mars_info = scrape_mars.scrape_mars_hemispheres()
    mars_mongo.update({},mars_info,upsert=True)
    return redirect("/")
コード例 #4
0
def scrape():

    # Run the scrape function
    mars_data = scrape_mars.scrape_mars_news()
    print(mars_data)
    # Update the Mongo database using update and upsert=True
    mongo.db.news_collection.update({}, mars_data, upsert=True)

    # Run the scrape function
    featured_image_url = scrape_mars.scrape_mars_image()
    print(featured_image_url)
    # Update the Mongo database using update and upsert=True
    mongo.db.image_collection.update({}, featured_image_url, upsert=True)

    # Run the scrape function
    mars_facts_data = scrape_mars.scrape_mars_facts()
    print(mars_facts_data)
    records = json.loads(mars_facts_data.T.to_json()).values()
    mongo.db.facts_collection.drop()
    mongo.db.facts_collection.insert(records)

    # Run the scrape function
    mars_hems_data = scrape_mars.scrape_mars_hemispheres()
    print(mars_hems_data)
    mongo.db.mars_hems_data.update({}, mars_hems_data, upsert=True)

    # Redirect back to home page
    return redirect("/")
コード例 #5
0
ファイル: app.py プロジェクト: jgmaspons/python-challenge
def scrape():

    mars_data = scrape_mars.scrape_mars_data_news()
    mars_images = scrape_mars.scrape_mars_images()
    mars_weather = scrape_mars.scrape_mars_weather()
    mars_facts = scrape_mars.scrape_mars_facts()
    #mars_hemispheres = scrape_mars.scrape_mars_hemispheres()

    mars_all_data = {}
    mars_all_data['news_title'] = mars_data['news_title']
    mars_all_data['results_paragraph'] = mars_data['results_paragraph']
    mars_all_data['feature_image_url'] = mars_images['feature_image_url']
    mars_all_data['mars_weather_result'] = mars_weather['mars_weather_result']
    mars_all_data['mars_facts_table'] = mars_facts['mars_facts_table']
    mars_all_data['mars_hemispheres'] = scrape_mars.scrape_mars_hemispheres()

    db.collection.update({}, mars_all_data, upsert=True)

    print(mars_data)
    print(mars_images)
    print(mars_weather)
    print(mars_facts)
    #print(mars_hemispheres)

    return redirect("/")
コード例 #6
0
def scrape():

    # Run the scrape function and save the results to a variable

    news_results = scrape_mars.scrape_news_info()

    featured_results = scrape_mars.scrape_featured_image()

    weather_results = scrape_mars.scrape_weather_info()

    facts_results = scrape_mars.scrape_mars_facts()

    images_results = scrape_mars.scrape_full_res_images()

    results = {
        'news': news_results,
        'featured_image': featured_results,
        'weather': weather_results,
        'facts': facts_results,
        'hemispheres': images_results
    }

    # Update the Mongo database using update and upsert=True

    mongo.db.mars_data.update({}, results, upsert=True)
    # Redirect back to home page
    return redirect("/")
コード例 #7
0
ファイル: app.py プロジェクト: DAVPRIK/web-scraping-challenge
def scrape():
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
コード例 #8
0
def scrape():

    mars_db = mongo.db.mars_db
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_db.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #9
0
def scrape():
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_featured_image()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemisphere()

    mongo.db.collection.update({}, mars_data, upsert=True)

    return redirect("/", code= 302)
コード例 #10
0
def scrape():
    mission_to_mars = mongo.db.mission_to_mars
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemisphere()
    mission_to_mars.update({}, data, upsert=True)

    return redirect("/", code=302)
コード例 #11
0
def scrape():
    mars_data = db.mars_info
    mars_fact = scrape_mars.scrape_mars_news()
    mars_fact = scrape_mars.scrape_mars_image()
    mars_fact = scrape_mars.scrape_mars_weather()
    mars_fact = scrape_mars.scrape_mars_facts()
    mars_fact = scrape_mars.scrape_mars_hemispheres()
    mars_data.update({}, mars_fact, upsert=True)
    # redirecting the route we are the code
    return redirect("/", code=302)
コード例 #12
0
def scrape():

    # Run scrapped functions
    mars_info = scrape_mars.scrape_mars_news()
    mars_info = scrape_mars.scrape_mars_image()
    mars_info = scrape_mars.scrape_mars_facts()
    mars_info = scrape_mars.scrape_mars_weather()
    mars_info = scrape_mars.scrape_mars_hemispheres()
    mongo.db.mars_collection.update({}, mars_info, upsert=True)

    return redirect("/", code=302)
コード例 #13
0
def scrape():
    # Run scraped functions
    mars_info = mongo.db.scrape_mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/") 
コード例 #14
0
def scrape():

    # Run scrapped functions
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_images()
    mars_f = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemi()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #15
0
def scrape():

    mars_results = mongo.db.mars_results
    mars_data = scrape_mars.scrape_nasa_news()
    mars_data = scrape_mars.scrape_nasa_image()
    mars_data = scrape_mars.scrape_mars_twitter()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemisphere()
    mars_results.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #16
0
def scrape():

    # Run scrapped functions
    mars_dict = mongo.db.mars_dict
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_featured_image()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    mars_dict.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #17
0
ファイル: app.py プロジェクト: miumiuannie/Mission-to-Mars
def scraper():
    mars_data = mongo.db.mars_data
    data = scrape_mars.scrape_mars_news()
    mars_data.update({}, data, upsert=True)
    data = scrape_mars.scrape_mars_images()
    mars_data.update({}, data, upsert=True)
    data = scrape_mars.scrape_mars_facts()
    mars_data.update({}, data, upsert=True)
    data = scrape_mars.scrape_mars_weather()
    mars_data.update({}, data, upsert=True)
    data = scrape_mars.scrape_mars_hemispheres()
    mars_data.update({}, data, upsert=True)
コード例 #18
0
ファイル: app.py プロジェクト: jyi9/UCI-Homework-Yi
def scraper():

    # run scraped functions
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    marsfacts = scrape_mars.scrape_mars_facts()
    marshem = scrape_mars.scrape_mars_hemispheres()
    marsimg = scrape_mars.scrape_mars_image()

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

    return redirect("/", code=302)
コード例 #19
0
ファイル: app.py プロジェクト: lhajnaj/CWRU_Data_Analytics
def scrape():

    # Run scrape functions
    mars_info = client.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)

    # return "Scraped!"
    return redirect("/", code=302)
コード例 #20
0
def scrape():

    # Run scrapped functions
    mars_info = mongo.db.mars_info
    mars_data = {}
    mars_data["news"] = scrape_mars.scrape_mars_news()
    mars_data["image"] = scrape_mars.scrape_mars_image()
    mars_data["facts"] = scrape_mars.scrape_mars_facts()
    mars_data["weather"] = scrape_mars.scrape_mars_weather()
    mars_data["hemispheres"] = scrape_mars.scrape_mars_hemispheres()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #21
0
def scrape():
    mars = mongo.db.mars
    # Run the scrape function
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    # Update the Mongo database using update and upsert=True
    mars.update({}, mars_data, upsert=True)
    # Redirect back to home page
    return redirect("/", code=302)
コード例 #22
0
def scrape():

    # Run scraped functions  
    mars_mission = mongo.db.mars_mission
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemisphers()
    
    mars_mission.update({}, mars_data, upsert=True)

    # Redirect back to home page
    return redirect("/", code=302)
コード例 #23
0
def scrape():

    # Run the scrape function
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_feat_image()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_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("/")
コード例 #24
0
ファイル: app.py プロジェクト: exu2011/web-scraping-challenge
def scrape():

    # Run scrapped functions
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_featured_image()
    mars_f = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_hemi()

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

    # Redirect back to home page
    return redirect("/", code=302)
コード例 #25
0
ファイル: app.py プロジェクト: tjmfindkim/Mission-to-Mars
def scrape(): 

    # Run scrapped functions
    mars_data = mongo.db.mars_final_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.jpl_mars_space_images()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_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("/")
コード例 #26
0
def scrape():

    # Run the scrape function
    mars_data = mongo.db.mars_data
    mars_info = {}

    mars_info['news'] = scrape_mars.scrape_mars_news()
    mars_info['featured'] = scrape_mars.scrape_mars_featured()
    mars_info['facts'] = scrape_mars.scrape_mars_facts()
    mars_info['mars_hemisphere'] = scrape_mars.scrape_mars_hemisphere()

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

    # Redirect back to home page
    return redirect("/")
コード例 #27
0
def scraper():
    # Run scrapped functions
    mars_info = mongo.db.mars
    mars_news = scrape_mars.scrape_mars_news()
    mars_image = scrape_mars.scrape_mars_image()
    mars_facts = scrape_mars.scrape_mars_facts()
    mars_weather = scrape_mars.scrape_mars_weather()
    mars_hemispheres = scrape_mars.scrape_mars_hemispheres()

    mars_data = mars_news
    mars_data.update(mars_image)
    mars_data.update(mars_facts)
    mars_data.update(mars_weather)
    mars_data.update(mars_hemispheres)

    mars_info.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
コード例 #28
0
ファイル: app.py プロジェクト: juicefire24/Web_Scrapping
def scrape(): 
   # Run scraping function
    # news = scrape_mars.scrape()

    # Store results into a dictionary

# Run scrapped functions
    #mars_info = mongo.mars_facts.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    mars_data = scrape_mars.scrape_mars_image()
    mars_data = scrape_mars.scrape_mars_facts()
    mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    #mars_info.update({}, mars_data, upsert=True)
    mongo.db.mars_facts.insert_one(mars_data)

    return redirect("/", code=302)
コード例 #29
0
def scrape(): 

    # Run scrapped functions
    # mars_info = mongo.db.mars_info
    # mars_data = scrape_mars.scrape()
    # mars_info.update({}, mars_data, upsert=True)
    # return redirect("/", code=302)
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_mars_news()
    print(mars_data)
    mars_data = scrape_mars.scrape_mars_image()
    print(mars_data)
    mars_data = scrape_mars.scrape_mars_facts()
    print(mars_data)
    # mars_data = scrape_mars.scrape_mars_weather()
    mars_data = scrape_mars.scrape_mars_hemispheres()
    print(mars_data)
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
コード例 #30
0
def scrape():

    # Run the scrape functions
    mars_table = mongo.db.mars_information
    news_title, news_paragraph = scrape_mars.scrape_mars_news()
    featured_img_url = scrape_mars.scrape_mars_image()
    mars_facts = scrape_mars.scrape_mars_facts()
    mars_hemispheres = scrape_mars.mars_hemispheres()

    mars_information = {
        "news_title": news_title,
        "news_paragraph": news_paragraph,
        "featured_image_url": featured_img_url,
        "mars_table": mars_facts,
        "hemisphere_image_urls": mars_hemispheres
    }

    print(mars_information)
    mars_table.update({}, mars_information, upsert=True)

    # Redirect back to home page
    return redirect("/", code=302)