def scrape(): # mars news mars_news_junk = scrape_mars.mars_news() mars_dict["mn_title"] = mars_news_junk[0] mars_dict["mn_para"] = mars_news_junk[1] # featured image mars_featured_image_link = scrape_mars.mars_feat_image() mars_dict["mfi"] = mars_featured_image_link # mars weather mars_latest_weather = scrape_mars.mars_weather() mars_dict["mw"] = mars_latest_weather # mars hemispheres # hemi 1 mars_hemi1_list = scrape_mars.mars_hemi1() mars_dict["mh1_title"] = mars_hemi1_list[0] mars_dict["mh1_link"] = mars_hemi1_list[1] # hemi 2 mars_hemi2_list = scrape_mars.mars_hemi2() mars_dict["mh2_title"] = mars_hemi2_list[0] mars_dict["mh2_link"] = mars_hemi2_list[1] # hemi 3 mars_hemi3_list = scrape_mars.mars_hemi3() mars_dict["mh3_title"] = mars_hemi3_list[0] mars_dict["mh3_link"] = mars_hemi3_list[1] # hemi4 mars_hemi4_list = scrape_mars.mars_hemi4() mars_dict["mh4_title"] = mars_hemi4_list[0] mars_dict["mh4_link"] = mars_hemi4_list[1] # insert the updated dictionary into Mongo # Insert the document into the database collection.insert_one(mars_dict) return redirect("http://localhost:5000/", code=302)
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(): collection.insert_many(scrape_mars.mars_news()) collection.insert_many( [ {'featured_img_full': scrape_mars.JPL_images()} ] ) collection.insert_many(scrape_mars.Mars_Facts()) collection.insert_many(scrape_mars.Mars_Hemispheres()) return redirect("/")
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 scraper(): # scrape_mars.scrape() is a custom function that we've defined in the scrape_mars.py file within this directory mars_info mars_data = scrape_mars.mars_news() mars_data = scrape_mars.featured_image() mars_data = scrape_mars.mars_weather() mars_data = scrape_mars.mars_facts() mars_data = scrape_mars.mars_hemi() mars_info.update({},mars_data, upsert=True) # Use Flask's redirect function to send us to a different route once this task has completed. 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(): mars_info = mongo.db.mars_info #Return scrape function mars_data = scrape_mars.mars_news() mars_data = scrape_mars.jpl_mars_space() mars_data = scrape_mars.mars_weather() mars_data = scrape_mars.mars_hemi() mars_data = scrape_mars.mars_df() # Update the Mongo database using update and upsert=True mars_info.update({}, mars_data, upsert=True) # Redirect back to home page return redirect("/")
def scrape(): # Run scraped functions news = scrape_mars.mars_news() featured_image = scrape_mars.JPL_image() mars_weather = scrape_mars.mars_weather() table = scrape_mars.mars_fact() dynamic_dic = { "news_title": news.title, "news_p": news.news, "featured_image": featured_image, "weather": mars_weather, "facts": table } # Insert into database collection1.insert_one(dynamic_dic) # Redirect back to home page 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)