Esempio n. 1
0
def scrape():
    # Scrape for mars news data
    news_data = mongo.db.news_data
    news_scrape_data = scrape_mars.scrape_news()
    news_data.update({}, news_scrape_data, upsert=True)

    # Scrape for mars images data
    images_data = mongo.db.images_data
    images_scrape_data = scrape_mars.scrape_images()
    images_data.update({}, images_scrape_data, upsert=True)

    # Scrape for mars weather data
    weather_data = mongo.db.weather_data
    weather_scrape_data = scrape_mars.scrape_weather()
    weather_data.update({}, weather_scrape_data, upsert=True)

    # Scrape for mars facts data
    facts_data = mongo.db.facts_data
    facts_scrape_data = scrape_mars.scrape_facts()
    facts_data.update({}, facts_scrape_data, upsert=True)

    # Scrape for mars hemisphere data
    hemi_data = mongo.db.hemi_data
    hemi_scrape_data = scrape_mars.scrape_hemi()
    hemi_data.update({}, hemi_scrape_data, upsert=True)

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

    # Run scraped functions
    
    news = scrape_mars.scrape_news()
    jpl = scrape_mars.scrape_jpl()
    weather = scrape_mars.scrape_weather()
    facts = scrape_mars.scrape_facts()
    hemi = scrape_mars.scrape_hemisphere()
    
    # Store results into a dictionary
    mars_data = {
        "news_title": news["news_title"],
        "news_p": news["news_p"],
        "featured_image_url": jpl["featured_image_url"],
        "mars_weather": weather["mars_weather"],
        "mars_facts": facts["mars_facts"],
        "mars_hemisphere": hemi["mars_hemisphere"],
    }
    # Remove old record
    mongo.db.collection.remove({})
    # Insert forecast into database
    mongo.db.collection.insert_one(mars_data)

    # Redirect back to home page
    return redirect("/", code=302)
Esempio n. 3
0
def scrape():
    result_dict = {}
    db = client.mars_db
    db.news_collection.drop()
    db.mars_fact.drop()
    db.mars_weather.drop()
    db.mars_featured_images.drop()
    db.scrape_hemispheres_images.drop()
    db.news_collection.insert_many(scrape_news())
    db.mars_fact.insert_one(scrape_facts())
    db.mars_featured_images.insert_many(scrape_featured_images())
    db.scrape_hemispheres_images.insert_many(scrape_hemispheres_images())
    db.mars_weather.insert_many(scrape_weather())
    result_dict['facts'] = list(db.mars_fact.find({}, {"_id": 0}))
    result_dict['hemispheres'] = list(
        db.scrape_hemispheres_images.find({}, {"_id": 0}))
    result_dict['news'] = list(
        db.news_collection.find({}, {
            "_id": 0
        }).limit(2))
    result_dict['weather'] = list(
        db.mars_weather.find({}, {
            "_id": 0
        }).limit(2))
    result_dict['featured'] = list(
        db.mars_featured_images.find({}, {
            "_id": 0
        }).limit(2))
    return render_template("index.html", result_dict=result_dict)
Esempio n. 4
0
def scraper():
    mars_data = mongo.db.mars_data
    mars_info = scrape_mars.scrape_news()
    mars_info = scrape_mars.scrape_image()
    mars_info = scrape_mars.scrape_weather()
    mars_info = scrape_mars.scrape_facts()
    mars_info = scrape_mars.scrape_hemispheres()
    mars_data.update({}, mars_info, upsert=True)
    return redirect("/", code=302)
Esempio n. 5
0
def scrape():
    mars_info = mongo.db.mars_data
    mars_data = scrape_mars.scrape()
    mars_data = scrape_mars.scrape_img()
    mars_data = scrape_mars.scrape_weather()
    mars_data = scrape_mars.scrape_facts()
    mars_data = scrape_mars.scrape_hems()
    
    #return to home
    return redirect('/')
Esempio n. 6
0
def scrape():
    # Run the scrape functions
    mars_data = scrape_mars.scrape_news()
    mars_data = scrape_mars.scrape_image()
    mars_data = scrape_mars.scrape_facts()
    mars_data = scrape_mars.scrape_weather()
    mars_data = scrape_mars.scrape_hemis()
    # Update the Mongo database using update and upsert=True
    mongo.db.collection.update({}, mars_data, upsert=True)

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

    all_mars_info = mongo.db.all_mars_info
    new_data = scrape_mars.scrape_news()
    new_data = scrape_mars.scrape_image()
    new_data = scrape_mars.scrape_facts()
    new_data = scrape_mars.scrape_hemispheres()
    new_data = scrape_mars.scrape_weather()

    all_mars_info.update({}, new_data, upsert=True)

    return redirect("/", code=302)
Esempio n. 8
0
def scrape():
    
    mars_db=mongo.db.mars_db
    mars_data=scrape_mars.scrape_news()
    mars_data=scrape_mars.scrape_img()
    mars_data=scrape_mars.scrape_weather()
    mars_data=scrape_mars.scrape_facts()
    mars_data=scrape_mars.scrape_hemispheres()

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

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

    # Run scrapped functions
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_news()
    mars_data = scrape_mars.scrape_image()
    mars_f = scrape_mars.scrape_facts()
    mars_w = scrape_mars.scrape_weather()
    mars_data = scrape_mars.scrape_hemisphere()
    mars_info.update({}, mars_data, upsert=True)

    return redirect("/", code=302)
Esempio n. 10
0
def scrape():
    # Run scraped functions
    scrape_data = mongo.db.scrape_data
    mars_data = scrape_mars.scrape_nasa()
    mars_data = scrape_mars.scrape_image()
    mars_data = scrape_mars.scrape_weather()
    mars_data = scrape_mars.mars_facts()
    mars_data = scrape_mars.hemispheres()
    print(mars_data)
    scrape_data.update({}, mars_data, upsert=True)

    #Redirecting back to home page
    return redirect("/", code=302)
Esempio n. 11
0
def scrape():
    mars_info = mongo.db.mars_info
    # Run the scrape function

    mars_content = scrape_mars.scrape_mars_news()
    mars_content = scrape_mars.scrape_img()
    mars_content = scrape_mars.scrape_weather()
    mars_content = scrape_mars.scrape_facts()
    mars_content = scrape_mars.scrape_hemisphere()

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

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

    # Run the scrape function
    mars_info = mongo.db.mars_info

    mars_data = scrape_mars.scrape_news()
    mars_data = scrape_mars.scrape_feature()
    mars_data = scrape_mars.scrape_facts()
    mars_data = scrape_mars.scrape_weather()
    # mars_data = scrape_mars.scrape_hemispheres()

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

    # Redirect back to home page
    return redirect("/", code=302)
Esempio n. 13
0
def home():
	feat_img = scrape_mars.scrape_featured()
	weather = scrape_mars.scrape_weather()
	hemi = scrape_mars.scrape_hemispheres()
	#fetch news data from mongodb
	news_data = mongo.db.collection_news.find()
	profile, comp = scrape_mars.scrape_facts()

	return render_template("index.html", 
		feat_img=feat_img, 
		weather=weather, 
		hemi=hemi, 
		news_data=news_data, 
		profile=profile, 
		comp=comp)
Esempio n. 14
0
def scrape():

    # Run scraped functions
    mars_info = mongo.db.mars_info
    mars_data = scrape_mars.scrape_news()
    mars_data = scrape_mars.scrape_image()
    mars_data = scrape_mars.scrape_weather()
    mars_data = scrape_mars.scrape_facts()
    mars_data = scrape_mars.scrape_hemi_1()
    mars_data = scrape_mars.scrape_hemi_2()
    mars_data = scrape_mars.scrape_hemi_3()
    mars_data = scrape_mars.scrape_hemi_4()

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

    return redirect("/")
Esempio n. 15
0
def scraper():

    news = mongo.db.news
    news_data = scrape_mars.scrape_news()
    news.update({}, news_data, upsert=True)

    image = mongo.db.image
    image_data = scrape_mars.scrape_image()
    image.update({}, image_data, upsert=True)

    weather = mongo.db.weather
    weather_data = scrape_mars.scrape_weather()
    weather.update({}, weather_data, upsert=True)

    table = mongo.db.table
    table_data = scrape_mars.scrape_facts()
    table.update({}, table_data, upsert=True)

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

    # Run scraped functions
    news = scrape_mars.scrape_news()
    featured = scrape_mars.scrape_featured()
    weather = scrape_mars.scrape_weather()
    table = scrape_mars.scrape_table()
    images = scrape_mars.scrape_images()

    mars_data = {
        "news_title": news["news_title"],
        "news_p": news["news_p"],
        "featured_image_url": featured["featured_image_url"],
        "weather": weather["mars_weather"],
        "table": table["mars_table"],
        "images": images["hemisphere_image_url"]
    }
    # Insert forecast into database
    mongo.db.collection.insert_one(mars_data)

    # Redirect back to home page
    return redirect("http://localhost:5000/", code=302)
Esempio n. 17
0
def scrape():

    article_info = scrape_mars.scrape_article()
    mongo.db.articles.update({}, article_info, upsert=True)

    featured = scrape_mars.scrape_jpl()
    mongo.db.jpl.update({}, featured, upsert=True)

    weather_stuff = scrape_mars.scrape_weather()
    mongo.db.weather.update({}, weather_stuff, upsert=True)

    facts = scrape_mars.scrape_facts()
    mongo.db.facts.update({}, facts, upsert=True)

    images = scrape_mars.scrape_image()
    mongo.db.images.remove({})

    for image in images:

        mongo.db.images.insert(image)

    return redirect("/")
Esempio n. 18
0
def scrape():

    # Run scraped functions
    news = scrape_mars.scrape_news()
    weather = scrape_mars.scrape_weather()
    facts = scrape_mars.scrape_facts()
    hemispere = scrape_mars.scrape_hemisperes()

    # Store results into a dictionary
    listings = {
        "news_headline": news["news_headline"],
        "news_discription": news["news_discription"],
        "news_weather": weather["news_weather"],
        "mars_facts": facts["mars_facts"],
        "hemisperes": hemispere["hemisperes"]
    }

    # Insert forecast into database
    mongo.db.collection.insert_one(listings)

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