コード例 #1
0
def scrape():

    # Run the scrape function and saving results
    mars_data = scrape_mars.scrape_info()

    # Updating the mongo database
    mongo.db.collection.update({}, mars_data, upsert=True)

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

    # Run the scrape function
    render_mars = scrape_mars.scrape_info()
    print(render_mars)
    # Update the Mongo database using update and upsert=True
    marsgo.db.collection.update({}, render_mars, upsert=True)

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

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect("/")
コード例 #4
0
ファイル: app.py プロジェクト: david-fried/Web-Scraping-Demo
def scrape():

    # Run the scrape function
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_info()

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

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

    # Run the scrape function and save the results to a variable
    mars_data = scrape_mars.scrape_info()
    print(mars_data)
    # Update the Mongo database using update and upsert=True upsert --> update or insert
    
    mongo.db.collection.update({}, mars_data, upsert=True)

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

    # Run the scrape function
    mars_info = scrape_mars.scrape_info()
    #print(mars_info)

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

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

    # Run the scrape function
    scraped_mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page and return success code
    return redirect("/", code=302)  
コード例 #8
0
ファイル: app.py プロジェクト: shortpoet/cs_washu_bootcamp
def scrape():

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()
    print(mars_data)
    # Update the Mongo database using update and upsert=True
    mongo.db.collection.update({}, mars_data, upsert=True)
    test_data = mongo.db.collection.find_one()
    print(test_data)
    # Redirect back to home page
    return redirect("/")
コード例 #9
0
def scrape():

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

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

    mars = mongo.db.mars

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    return redirect('/')
コード例 #11
0
def scrape():
    #Make a shortcut to the database
    marsmission = mongo.db.marsmission
    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect(url_for('home'))
コード例 #12
0
def scrape():

    # Run the scrape function
    data = scrape_mars.scrape_info()

    db.mars_table.drop()
    # Update the Mongo database using update and upsert=True
    db.mars_table.insert_one(data)

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

    # Run the scrape function
    mars_dict = scrape_mars.scrape_info()

    # # Update the Mongo database
    mongo.db.facts.update({}, mars_dict, upsert=True)
    print("scrape done")

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

    # drop any data that is already in database
    db.mars_data.drop()
    mars_data = scrape_mars.scrape_info()

    # Update the Mongo database using update and upsert=True
    db.mars_data.insert_one(mars_data)

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

    # Run the scrape function and save the results to a variable
    mars = mongo.db.mars
    result_data = scrape_mars.scrape_info()

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

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

    # Run the scrape function
    nasa_data, mars_data, hemispheres_data = scrape_mars.scrape_info()
    mongo.db.nasa_details.update({}, nasa_data, upsert=True)
    mongo.db.mars_details.update({}, mars_data, upsert=True)
    mongo.db.hemisphere_details.drop()
    mongo.db.hemisphere_details.insert_many(hemispheres_data)

    # Redirect back to home page
    return redirect("/")
コード例 #17
0
def scrape():
    #run the scrape function 
    mars_data = scrape_mars.scrape_info()
    mars = mongo.db.mars
    mars.replace_one({},mars_data, upsert=True)

    #Update the Mongo database 
    #mongo.db.mars.update({}, mars_data, upsert = True)
    #Redirect back to home page
    #return "Scraping is done!"
    return redirect("/")
コード例 #18
0
ファイル: app.py プロジェクト: somotos1/web_scraping
def scrape():

    # Run the scrape function
    final_results = mongo.db.final_results
    final_results_data = scrape_mars.scrape_info()

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

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

    mars_info = mongo.db.mars_data

    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect("/", code=302)
コード例 #20
0
ファイル: app.py プロジェクト: jlheen/web-scraping-challenge
def scrape():
    # Find mongo database
    mars = mongo.db.mars

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return 'successful'
コード例 #21
0
def scrape():

    # Run the scrape function and save the results to a variable
    # @TODO: YOUR CODE HERE!
    page_data = scrape_mars.scrape_info()

    # Update the Mongo database using update and upsert=True
    # @TODO: YOUR CODE HERE!
    mongo.db.collection.update({}, page_data, upsert=True)

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

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect("/")
コード例 #23
0
def scrape():
    mars = mongo.db.mars
    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

    # Worked with t/a to ensure data was was loading into MongoDB properly

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

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

    # Delete all records
    mongo.db.collection.remove({})

    # Run the scrape function
    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect("/")
コード例 #25
0
def scrape():
    mongo.db.mars_collection.drop()
    # Run the scrape function
    all_mars_urls = scrape_mars.scrape_info()

    for url in all_mars_urls:
        # Dictionary to be inserted into MongoDB
        mongo.db.mars_collection.insert_one(url)

    # Update the Mongo database using update and upsert=True
    #collection.update({}, scrape_mars, upsert=True)
    # Redirect back to home page
    return redirect("/")
コード例 #26
0
def scrape():

    #Do a new Mars data scrape
    mars_data = scrape_mars.scrape_info()

    #Setup connection to mongodb
    conn = "mongodb://localhost:27017"
    client = pymongo.MongoClient(conn)

    # Select database and collection to use
    mars_info = db.mars_info
    mars_info.insert_one(mars_data)

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

    # Run the scrape function
    #Latest New titles and news paragrah
    mars_info = scrape_mars.scrape_info()
    #Featured Mars Image
    mars_info = scrape_mars.scrape_info2()
    #Mars Facts
    mars_info = scrape_mars.scrape_info3()
    #Mars Hemisphere
    mars_info = scrape_mars.scrape_info4()

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

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

    # news_title = "NASA Engineers Checking InSight's Weather Sensors"
    # news_p = "An electronics issue is suspected to be preventing the sensors from sharing their data about Mars weather with the spacecraft."
    # featured_image_url = "https://www.jpl.nasa.gov/spaceimages/images/largesize/PIA08003_hires.jpg"
    # img1_title = 'Cerberus Hemisphere Enhanced'
    # img1_url = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/cerberus_enhanced.tif/full.jpg'
    # img2_title = 'Schiaparelli Hemisphere Enhanced'
    # img2_url = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/schiaparelli_enhanced.tif/full.jpg'
    # img3_title = 'Syrtis Major Hemisphere Enhanced'
    # img3_url = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/syrtis_major_enhanced.tif/full.jpg'
    # img4_title = 'Valles Marineris Hemisphere Enhanced'
    # img4_url = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/valles_marineris_enhanced.tif/full.jpg'

    # mars_data = {
    #     "news_title": news_title,
    #     "news_p": news_p,
    #     "featured_image_url": featured_image_url,
    #     "img1_title": img1_title,
    #     "img1_url": img1_url,
    #     "img2_title": img2_title,
    #     "img2_url": img2_url,
    #     "img3_title":img3_title,
    #     "img3_url": img3_url,
    #     "img4_title": img4_title,
    #     "img4_url": img4_url,
    # }

    mars_data = scrape_mars.scrape_info()

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

    # Redirect back to home page
    return redirect("/")
コード例 #29
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_info()
    mars.replace_one({}, mars_data, upsert=True)

    return redirect("/")
コード例 #30
0
def scrapemaster():
    purpan = scrape_mars.scrape_info()
    mongo.db.collection.update({}, purpan, upsert=True)
    return redirect("/")