示例#1
0
def scrape():
    mars = mongo.db.mars
    mars_data = mission_to_mars.scrape()
    # Update the Mongo database using update and upsert=True
    mars.update({}, mars_data, upsert=True)
    # Redirect back to home page
    return redirect("/")
示例#2
0
def scraper():

    scrapings = mongo.db.scrapings

    scrapings_data = mission_to_mars.scrape()
    scrapings.update({}, scrapings_data, upsert=True)
    return redirect("/", code=302)
示例#3
0
def scrape():
    mars_dict = mongo.db.mars
    mars_data = mission_to_mars.scrape()
    print(mars_data)
    # Update the Mongo database using update and upsert=True
    mars_dict.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
示例#4
0
def scrape():

    mars_data = mission_to_mars.scrape()

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

    return redirect("/")
示例#5
0
def scrape():

    # db.collection.remove()
    mars = mission_to_mars.scrape()
    print("\n\n\n")
    db.mars_data.insert_one(mars)
    mars = list(db.mars_data.find())
    return render_template("index.html", mars=mars)
def scrape():
    '''Scrape mars data from internet, store into db'''
    mars_data = mission_to_mars.scrape()
    db.mars_collection.drop()
    db.mars_collection.insert_one(mars_data)
    mars_data = list(db.mars_collection.find())
    mars_data[0]['table_html'] = Markup(mars_data[0]['table_html'])
    return render_template('index.html', data=mars_data[0])
示例#7
0
def scrape():
    mars = mongo.db.mars
    data = mission_to_mars.scrape()
    mars.update(
        {},
        data,
        upsert=True
    )
    return redirect("http://localhost:5000/", code=302)
示例#8
0
def scrape():
    # Run the scrape function
    mars_data = mission_to_mars.scrape()

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

    # Redirect back to home page
    return redirect("/")
示例#9
0
def scraper():
    #Run the scrape function
    mars_data = mongo.db.mars_data
    mars_data_data = mission_to_mars.scrape()
    #Update the Mongo database using update and insert=True)
    mars_data.update({},mars_data_data,upsert=True)

    #Redirect back to the home page
    return redirect("/", code=302)
示例#10
0
def scrape():
    mars = mongo.db.mars
    mars_data = mission_to_mars.scrape()
    mars.update(
                {},
                mars_data,
                upsert=True
                )
    return redirect("/", code=302)
示例#11
0
def scraper():

    client.drop_database("missionToMarsDB")
    db = client.missionToMarsDB
    collection = db.scrape

    collection.insert_one(dict(scrape()))

    return redirect(url_for('home'))
示例#12
0
def scraper():
    # mars = mongo.db.mars_table
    mission_to_mars.scrape()
    # mars.update({}, mars_data, upsert=True)
    # db.mars_table.insert_many(
    # [
    #     {
    #         'news_t': 'news_t',
    #         'position': 'Point Guard'
    #     },
    #     {
    #         'player': 'Mark',
    #         'position': 'Center'
    #     }
    # ]
    # )

    return redirect("/", code=302)
示例#13
0
def scrapenow():
    mars = scrape()
    conn = 'mongodb://localhost:27017'
    client = pymongo.MongoClient(conn)
    db = client.marsdata
    db['data'].drop()
    data = db['data']
    data.insert_one(mars)
    
    return redirect('..')
示例#14
0
def scrape():

    data_dict = mission_to_mars.scrape()
    collection.insert_one(data_dict)
    
    results = collection.find(data_dict)
    for a in results:
        pprint(a)

    return render_template("index.html", mars_data = data_dict)
示例#15
0
def scrape_route():

    client.drop_database("missionToMarsDB")
    db = client.missionToMarsDB
    collection = db.scrape

    scrape_results = scrape()

    collection.insert_one(scrape_results)

    return redirect(url_for('home'))
示例#16
0
def scraper():
    mongo.db.drop_collection("collection")

    mars_dict = mtm.scrape()
    mars_info = {
        "news_title": mars_dict['news_title'],
        "news_p": mars_dict['news_p'],
        "featured_image_url": mars_dict['featured_image_url'],
        "mars_weather": mars_dict['mars_weather'],
        "mars_facts": mars_dict['mars_facts'],
        "hemis_list": mars_dict['hemis_list']
    }

    mongo.db.collection.insert_one(mars_info)
    return redirect("/", code=302)
示例#17
0
def scrape_route():

    #drop database
    client.drop_database("missionToMarsDB")
    # Run the scrape function
    db = client.missionToMarsDB
    collection = db.scrape

    scrape_results = scrape()

    collection.insert_one(scrape_results)

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

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

    # client = PyMongo.MongoClient(conn)

    # Connect to a database. Will create one if not already available.
    db = mongo.db.mars

    # Drops collection if available to remove duplicates
    db.mars_data.drop()
    marsDict = mission_to_mars.scrape()
    # Creates a collection in the database and inserts the dictionary
    db.mars_data.insert_one(marsDict)

    # browser.quit()
    return render_template("index.html",
                           items=marsDict,
                           image_urls=marsDict['hemisphere_imgs'])
示例#19
0
def scraper():
    # conn = 'mongodb://localhost:27017'
    # client = pymongo.MongoClient(conn)

    # Define the 'MarsInfo' database in Mongo
    mars_info_before = mongo.db.info

    # Assign results of web-scraping to variable mars_data
    mars_data = mission_to_mars.scrape()
    #mongo.db.info.insert_one(mars_data)

    app.config['MARS_hems'] = mars_data['Mars_Hemispheres']['url']
    #full_filename = os.path.join(app.config['MARS_hems'],'Mars_Hemispheres.png')
    full_filename = os.path.join(app.config['MARS_hems'])

    mars_data['Flask_Mars_Hems_URL'] = full_filename

    mars_info_before.update({}, mars_data, upsert=True)
    return redirect("/", code=302)
示例#20
0
def scraper():
    # Drop the information scraped last time
    mongo.db.drop_collection("collection")

    # Run scrape function and store the dictionary into a new dict
    mars_dict = mtm.scrape()
    mars_info = {
        "news_title": mars_dict['news_title'],
        "news_p": mars_dict['news_p'],
        "featured_image_url": mars_dict['featured_image_url'],
        "mars_weather": mars_dict['mars_weather'],
        "mars_facts": mars_dict['mars_facts'],
        "hemis_list": mars_dict['hemis_list']
    }

    # Insert the data into mongo database
    mongo.db.collection.insert_one(mars_info)
    # Redirect to index page after scraping
    return redirect("/", code=302)
示例#21
0
文件: app.py 项目: rbecerri/UT
def scraper():
    mongo.db.marsdata.drop()
    results = mission_to_mars.scrape()
    mongo.db.marsdata.insert_one(results)
    return redirect("/", code=302)
示例#22
0
def mars_scrape():
    collection.drop()
    mars_info = scrape()
    collection.insert_one(mars_info)
    return home()
示例#23
0
def scrape():
    mars = mongo.db.mars
    mars_data = mission_to_mars.scrape()
    mars.replace_one({}, mars_data, upsert=True)
    print(mars_data)
    return redirect("/")
示例#24
0
def scraper():
    mars_data = mongo.db.mars_data
    mars_webscrape_re = mission_to_mars.scrape()
    mars_data.update({}, mars_webscrape_re, upsert=True)
    return redirect("/", code=302)
示例#25
0
def run():
    find = mongo.db.find
    data = mission_to_mars.scrape()
    return "Scraping Successful!"
示例#26
0
def scrape():
    mars = mongo.db.mars
    mars_data = mission_to_mars.scrape()
    mars.update({}, mars_data, upsert=True)
    return "Scrapping done!"
def scraper():
    information = mongo.db.information
    information_data = mission_to_mars.scrape()
    # print(information_data)
    information.update({}, information_data, upsert=True)
    return redirect("/")
示例#28
0
def scrape():
    nasa_news = mongo.db.nasa_news
    nasa_news_data = mission_to_mars.scrape()
    nasa_news.update({}, nasa_news_data, upsert=True)
    return redirect("/", code=302)
示例#29
0
def scrape():
    data = mm.scrape()
    db_details.insert(data)
    return redirect("/", code=302)
示例#30
0
def scrape():
    mars = client.db.mars
    mars_data = mission_to_mars.scrape()
    mars.insert(mars_data)
    #mars.update({}, mars_data)
    return ("Scrape is complete! Go to /")