mission_to_mars

Scraping app that pulls data from various mar's related webpages. It then compiles the data, saves the data into mongoDB, and renders it into a clean, visually appealing html page.

View the Project on GitHub buitron/mission_to_mars

Mission to Mars

mission_to_mars

Objective

In this assignment, I will build a web application that scrapes various websites for data related to the Mission to Mars and displays the information in a single HTML page. The following outlines what I need to do.



Step 1 - Scraping

Complete the initial scraping using Jupyter Notebook, BeautifulSoup, Pandas, Requests/Splinter and/or a mix of these. Utilize whatever is need to complete the objective in the most efficient way possible.

NASA Mars News

# Example:
news_title = "NASA's Next Mars Mission to Investigate Interior of Red Planet"

news_p = "Preparation of NASA's next spacecraft to Mars, InSight, has ramped up this summer, on course for launch next May from Vandenberg Air Force Base in central California -- the first interplanetary launch in history from America's West Coast."
# Example:
featured_image_url = 'https://www.jpl.nasa.gov/spaceimages/images/largesize/PIA16225_hires.jpg'

Mars Weather

# Example:
mars_weather = 'Sol 1801 (Aug 30, 2017), Sunny, high -21C/-5F, low -80C/-112F, pressure at 8.82 hPa, daylight 06:09-17:55'

Mars Facts

Mars Hemisperes

# Example:
hemisphere_image_urls = [
    {"title": "Valles Marineris Hemisphere", "img_url": "..."},
    {"title": "Cerberus Hemisphere", "img_url": "..."},
    {"title": "Schiaparelli Hemisphere", "img_url": "..."},
    {"title": "Syrtis Major Hemisphere", "img_url": "..."},
]

Step 2 - MongoDB and Flask Application

Use MongoDB with Flask templating to create a new HTML page that displays all of the information that was scraped from the URLs above.



Solution

System Prep

In order to run this application you will need to have Python version 3.6.3 installed on your system. If you do not have it installed then you can read about how to install it here.

You’re also going to need MongoDB, an unstructured data storage management system, on your local system. In order to download and install it either follow the instructions here or brew install it, only if you already have the brew package manager installed, using this code in your bash coding application:

$ brew update
$ brew install mongodb

Afterwards download or clone this repository into your system and open up your system’s shell, preferably using the terminal application running the bash shell. From there follow these instructions in order to install the required modules…

  1. Move into the directory where this repo is stored:
    $ cd /path/to/mission_to_mars/
    
  2. pip install the modules from the requirements.txt file:
    $ pip install -r requirements.txt
    

You’re now ready to run this bad boy!


Executing the Flask App

Follow these instructions sequentially in order to launch the application.

  1. Open your bash application and start up the mongodb server by typing in and executing the following code:
    $ mongod
    
  2. Open up another terminal tab or window and cd into the solution/ directory of this repo. Type the following code to move into and execute the flask app mars.py:
$ cd /path/to/mission_to_mars/solution/
$ python mars.py

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: ***-***-***
127.0.0.1 - - [01/Jan/2000 01:01:01] "GET / HTTP/1.1" 200 -
  1. Congrats! The application is running successfully. Now, to view the result in a browser open up any browser, preferably anything but Internet Explorer, unless you really hate your life then be my guest. Type localhost:5000 into the url bar and the application should open. Just press the Scrape that Data Up button and wait a few seconds while the application does its thing and gathers the data before presenting it to you. The webpage should look similar to this after it is done processing…

final_app_part1.png final_app_part2.png

UPDATE! I am now Hosting this App on Heroku

Click HERE to try it out