def scrape(): mars_data = mongo.db.mars_data mars_info = scrape_mars.title_scrape() mars_info = scrape_mars.paragraph_scrape() mars_info = scrape_mars.image_scrape() mars_info = scrape_mars.twitter_scrape() mars_info = scrape_mars.facts_scrape() mars_info = scrape_mars.hems_scrape() mars_data.update({}, mars_info, upsert=True) return redirect("/", code=302)
def scrape(): mars_data = mongo.db.mars_data mars_report = scrape_mars.news_scrape() mars_report = scrape_mars.image_scrape() mars_report = scrape_mars.facts_scrape() mars_report = scrape_mars.weather_scrape() mars_report = scrape_mars.hemispheres_scrape() mars_data.update({}, mars_report, upsert=True) return redirect("/", code=302)
def scraper(): scraped_miss_mars = mongo.db.scraped_miss_mars headlines = scrape_mars.news_scrape() images = scrape_mars.image_scrape() tweets = scrape_mars.tweet_scrape() facts = scrape_mars.table_scrape() hemispheres = scrape_mars.hemisphere_img_scrape() updates = { "headlines": headlines, "images": images, "tweets": tweets, "facts": facts, "hemispheres": hemispheres } scraped_miss_mars.update({}, updates, upsert=True) return redirect("/", code=302)
def scrape(): # Run the scrape function mars_data = mongo.db.scraped_mars headlines = scrape_mars.news_scrape() images = scrape_mars.image_scrape() tweets = scrape_mars.tweet_scrape() facts = scrape_mars.table_scrape() hemispheres = scrape_mars.hemisphere_img_scrape() update_data = { "headlines": headlines, "images": images, "tweets": tweets, "facts": facts, "hemispheres": hemispheres } mars_data.update({}, update_data, upsert=True) return redirect("/", code=302)
def scrape(): mars = mongo.db.mars mars_data = {} # Run the scrape function print("Start scraping") try: mars_data['news'] = scrape_mars.news_scrape() except Exception as e: print("Fail to scrape news") raise e try: mars_data['image'] = scrape_mars.image_scrape() except: print("Fail to scrape image") try: mars_data['weather'] = scrape_mars.weather_scrape() except: print("Fail to scrape weather") try: mars_data['facts'] = scrape_mars.mars_facts() except: print("Fail to scrape facts") try: mars_data['hemi'] = scrape_mars.hemi_scrape() except: print("Fail to scrape hemi") print("End scrape") # Update the Mongo database using update and upsert=True mars.update({}, mars_data, upsert=True) return redirect("/")