def scraper():
    data = mars.scrape()

    client = MongoClient(port=27017)
    db = client.mars
    db.mars_data.update({}, data, upsert=True)

    return redirect("/", code=302)
Esempio n. 2
0
def index():

    # Store the entire team collection in a list
    mars_list = list(mars_db.mars_data.find())
    print(mars_list)

    form = InfoForm()
    if form.validate_on_submit():
        x = scrape_mars.scrape()
        mars_db.mars_data.insert_many(x)
        return render_template("index.html", form=form, mars=mars_list)
    # Return the template with the teams list passed in
    return render_template("index.html", form=form, mars=mars_list)
Esempio n. 3
0
# Create connection variable
# conn = 'mongodb://*****:*****@roas15-30p3e.mongodb.net"

# Pass connection to the pymongo instance.
client = pymongo.MongoClient(conn)

# Connect to a database. Will create one if not already available.
mars_db = client.mars_db

# Drops collection if available to remove duplicates
mars_db.mars_data.drop()

# Scrape the web
x = scrape_mars.scrape()

# Creates a collection in the database and inserts two documents
mars_db.mars_data.insert_many(x)


class InfoForm(FlaskForm):
    submit = SubmitField("Scrape")


# Set route
@app.route("/index.html")
@app.route("/", methods=["GET", "POST"])
def index():

    # Store the entire team collection in a list
Esempio n. 4
0
def scrape():
    model.createDataBase(scrape_mars.scrape())
    return 'True'
Esempio n. 5
0
def scrape():
    mars = scrape_mars.scrape()
    print("\n\n\n")

    db.mars_facts.insert_one(mars)
    return "Some scrapped data"