Beispiel #1
0
def scrape():
    mars = mongo.db.mars
    # Run the scrape function to retrieve mars table data in dictionary format
    mars_data = scrape_mars.scrape_all()
    print(mars_data)

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

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

    #Run scrape function
    mars_data = scrape_mars.scrape_all()

    #Update Mongo DB using update and upsert

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

    #Redirect to home page
    return redirect("/")
def scrapper():

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

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

    # Redirect back to home page
    return redirect("/")
Beispiel #4
0
def scrape():
    # drops collection for duplicates
    mongo.db.mars_data.drop()

    # Run scrape_all
    mars_data = scrape_mars.scrape_all()

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

    # Redirect back to home page
    return redirect("/")
Beispiel #5
0
def scrape():

    mars_dataDB = mongo.db.mars_data_collected

    mars_data = scrape_mars.scrape_all()

    #Update the mongo datase using update and upsert=True

    mars_dataDB.update({}, mars_data, upsert=True)

    # Redirect back to home page

    return redirect("/", code=302)
Beispiel #6
0
def scrape():

    # Run scraped functions
    mars_data_scrape = scrape_mars.scrape_all()

    # Inserting mars_data into database
    # mongo.db.mars.update(mars_data_scrape)
    mongo.db.mars.insert_one(mars_data_scrape)
    # mongo.mars_db.mars_collection.update({}, mars_data_scrape, upsert=True)

    # Redirect back to home page
    # return redirect("/", code=302)
    return home()
Beispiel #7
0
def scrape():

    martian_data = scrape_mars.scrape_all()
    '''
    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()'''
    mongo.db.collection.update({}, martian_data, upsert=True)
    #mars_info.update({}, mars_data, upsert=True)

    return redirect("/")
def scrape():

    # Run the scrape function
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.replace_one({}, mars_data, upsert=True)
    return "Scraping Successful!"

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

    if __name__ == "__main__":
        app.run(debug=True)
Beispiel #9
0
def scraper():
    # Create the database collection and collection object
    mars_data_collection = mongo.db.mars_data

    # Empty the contents of the database to prevent duplicate data
    mongo.db.drop_collection(mars_data_collection)

    # Store the latest URL data into the dict
    data_dict = scrape_mars.scrape_all()
    print(data_dict)
    # Update the database
    mars_data_collection.insert(data_dict)
    return redirect("/", code=302)
Beispiel #10
0
def scrape():

    import scrape_mars

    # Gather document to insert
    nasa_document = scrape_mars.scrape_all()

    # Insert into the mars collection
    # mars.insert_one(data_document)

    # Upsert into database (preferred to avoid duplicates)
    mars_coll.update_one({}, {'$set': nasa_document}, upsert=True)

    return redirect('/')
def scrape():

    # Create a mongo database
    mars_db = mongo.db.mars

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

    print(mars_data)

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

    # Redirect back to home page
    return redirect("/")
Beispiel #12
0
def scrape():

    # this is the py script with all of the scraping functions
    import scrape_mars

    # Gather document to insert
    nasa_document = scrape_mars.scrape_all()

    # Insert into the mars collection
    # mars_coll.insert_one(nasa_document)

    # Upsert into the mars collection (preferred to avoid duplicates)
    mars_coll.update_one({}, {'$set': nasa_document}, upsert=True)

    return redirect('/')
def scrape():
    
    #create Mongo data base
    dic_db=mongo.db.dic

    # Run the scrape function
    dic_data = scrape_mars.scrape_all() 
    
    print(dic_data)
   
    # Update the Mongo database using update and upsert=True
    dic=mongo.db.collection.update({}, dic_data, upsert=True)
    
       
    # Redirect back to home page
    return redirect("/", code=302)
Beispiel #14
0
def scrape():

    # Run scrape function
    scraped = scrape_mars.scrape_all()

    # Store results into a dictionary
    mars_data = {
        "content_title": scraped["content_title"],
        "content_paragraph": scraped["content_paragraph"],
        "featured_image_url": scraped["featured_image_url"],
        "mars_weather": scraped["mars_weather"],
        "html_table": scraped["html_table"],
        "hemisphere_image_urls": scraped["hemisphere_image_urls"]
    }

    # hemisphere_1 = {scraped["hemisphere_1"]}
    # hemisphere_2 = {scraped["hemisphere_2"]}
    # hemisphere_3 = {scraped["hemisphere_3"]}
    # hemisphere_4 = {scraped["hemisphere_4"]}

    # Delete collections and create again to reset data
    mongo.db.scrape.drop()
    mongo.db.create_collection("scrape")
    # mongo.db.hemisphere_1.drop()
    # mongo.db.create_collection("hemisphere_1")
    # mongo.db.hemisphere_2.drop()
    # mongo.db.create_collection("hemisphere_2")
    # mongo.db.hemisphere_3.drop()
    # mongo.db.create_collection("hemisphere_3")
    # mongo.db.hemisphere_4.drop()
    # mongo.db.create_collection("hemisphere_4")

    # Insert entry into database
    mongo.db.scrape.insert_one(mars_data)
    # mongo.db.hemisphere_1.insert_one(hemisphere_1)
    # mongo.db.hemisphere_2.insert_one(hemisphere_2)
    # mongo.db.hemisphere_3.insert_one(hemisphere_3)
    # mongo.db.hemisphere_4.insert_one(hemisphere_4)

    # Redirect back to home page
    return redirect("http://localhost:5000/", code=302)
Beispiel #15
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return "Scraping Successful!"
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    message = "Scraping Successful!"
    return redirect("/")
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return render_template("index.html", mars=mars_data)
Beispiel #18
0
def scrape():
    mars = mongo.db.mars
    mars_info = scrape_mars.scrape_all()
    mars.update({}, mars_info, upsert=True)
    return redirect("/")
def scrape():
    mars = client.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return redirect('/')
Beispiel #20
0
def scrapper():
    # Run the scrape function
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return "Scraping Successful"
Beispiel #21
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return redirect('/', code= 302)
def scraper():
    mars_data = scrape_mars.scrape_all()
    db.mars.delete_many({})
    db.mars.insert_many([mars_data])
    return ('Done!')
def index():
    mars_data = scrape_mars.scrape_all()
    db.mars.delete_many({})
    db.mars.insert_many([mars_data])
    return render_template("index.html", mars=mars_data)
Beispiel #24
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return "Done"
Beispiel #25
0
def scraper():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all(
    )  #calls the function to get all the scrapings and store in mars
    mars.update({}, mars_data, upsert=True)
    return "Scraping Succesfull"
Beispiel #26
0
def scrape():
    scrape_data = scrape_all()
    mongo.db.mars_data.update({}, scrape_data, upsert=True)
    return redirect('/')
Beispiel #27
0
def scraper():
    mars = mongo.db.mars_collection
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
Beispiel #28
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    print(mars_data)
    return "Successful Scrape"
Beispiel #29
0
def scrape():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.replace_one({}, mars_data, upsert=True)

    return redirect("/")
def scrapper():
    mars = mongo.db.mars
    mars_data = scrape_mars.scrape_all()
    mars.update({}, mars_data, upsert=True)
    return redirect("/")