def scrape(): # Run the scrape title and para function title_and_paragraph = scrape_mars.title_and_para() mongo.db.title_and_para_col.update({}, title_and_paragraph, upsert=True) # Run and scrape featured image function mars_image = scrape_mars.mars_image() mongo.db.featured_image_col.update({}, mars_image, upsert=True) # # Run and scrape mars_weather function """ mars_facts = scrape_mars.mars_weather() mongo.db.mars_weather_col.update({}, mars_facts, upsert=True) """ # Run and scrape mars_hemisphere function mars_hemis_image = scrape_mars.mars_hemis() # Image 1 mars_img1 = mars_hemis_image[0] mongo.db.mars_img1_col.update({}, mars_img1, upsert=True) # Image 2 mars_img2 = mars_hemis_image[1] mongo.db.mars_img2_col.update({}, mars_img2, upsert=True) # Image 3 mars_img3 = mars_hemis_image[2] mongo.db.mars_img3_col.update({}, mars_img3, upsert=True) # Image 4 mars_img4 = mars_hemis_image[3] mongo.db.mars_img4_col.update({}, mars_img4, upsert=True) # Redirect back to home page return redirect("/")
def scrape(): mars_data = scrape_mars.mars_news() mars_data = scrape_mars.mars_image() mars_data = scrape_mars.mars_facts() mars_data = scrape_mars.mars_weather() mars_data = scrape_mars.mars_hemispheres() mongo.db.mars_info.update({}, mars_data, upsert=True) return redirect("/", code=302)
def scrape(): # Run scrapped functions mars_info = mongo.db.mars_info mars_data = scrape_mars.mars_news() mars_data = scrape_mars.mars_image() mars_data = scrape_mars.mars_facts() mars_data = scrape_mars.mars_hemispheres() mars_info.update({}, mars_data, upsert=True) return redirect("http://localhost:5000/", code=302)
def scrape(): #Run the scrape function mars_info = mongo.db.mars_info mars_data = scrape_mars.mars_news() mars_data = scrape_mars.mars_image() mars_data = scrape_mars.mars_twitter() mars_data = scrape_mars.mars_facts() mars_data = scrape_mars.mars_hemispheres() mars_info.update({}, mars_data, upsert=True) return redirect("/", code=302)
def scrape(): mars = mongo.db.collection mars_info = scrape_mars.scrape() mars_info = scrape_mars.mars_image() # mars_info = scrape_mars.mars_weather() mars_info = scrape_mars.mars_facts() mars_info = scrape_mars.mars_hemispheres() mars.update({}, mars_info, upsert=True) return redirect("/")
def scrape(): # Run the scrape function mars_data = scrape_mars.mars_news() mars_data = scrape_mars.mars_image() mars_data = scrape_mars.mars_weather() mars_data = scrape_mars.mars_facts() mars_data = scrape_mars.mars_hemispheres() # Update the Mongo database using update and upsert=True mongo.db.collection.update({}, mars_data, upsert=True) # Redirect back to home page return redirect("/")
def scrape(): news = scrape_mars.mars_news() image = scrape_mars.mars_image() weather = scrape_mars.mars_weather() facts = scrape_mars.mars_facts() hemispheres = scrape_mars.mars_hemispheres() db.news.insert_one(news) db.image.insert_one(image) db.weather.insert_one(weather) for fact in facts: db.facts.insert_one(fact) for hemisphere in hemispheres: db.hemispheres.insert_one(hemisphere) return redirect("http://localhost:5000/", code=302)
def scrape(): news = scrape_mars.mars_news() try: db.news.insert_many(news) print("News Uploaded!") except TypeError as e: print("Mars News Error" + e) #Get featured image mars_pic = scrape_mars.mars_image() try: db.featured.insert_one(mars_pic) print("Feature Image Uploaded!") except TypeError as e: print("Feature Image Error" + e) #Get latest weather from Twitter weather = scrape_mars.mars_weather() try: db.weather.insert_one(weather) print("Weather Uploaded!") # Get mars facts table except TypeError as e: print("Weather Tweet Error" + e) facts = scrape_mars.mars_facts() try: db.facts.insert_one(facts) print("Facts Uploaded!") # Get images of mars hemispheres except TypeError as e: print("Mars Facts Error" + e) hems = scrape_mars.mars_hemispheres() try: db.images.insert_many(hems) print("Hemispheres Uploaded!") except TypeError as e: print("Hemisphere scrape error" + e)