Skip to content

This project scrapes the web to build an application for Mission to Mars data. Demonstrates use of Beautiful Soup, Pandas, Splinter, MongoDB, HTML, and CSS.

Notifications You must be signed in to change notification settings

ajcascella/Mission-To-Mars-Web-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background

For this project I built a web application that scrapes various websites for data related to the Mission to Mars and displays the information in a single HTML page.

For the initial scraping I used Jupyter Notebook, BeautifulSoup, Pandas, and Requests/Splinter.

Step 1 - Scrape the Web

NASA Mars News

JPL Mars Space Images - Featured Image

  • Visited the url for JPL Featured Space Image here.

  • Used splinter to navigate the site and find the full size .jpg image url for the current Featured Mars Image.

Mars Weather

  • Visited the Mars Weather twitter account here and scraped the latest Mars weather tweet from the page.

Mars Facts

  • Visited the Mars Facts webpage here and used Pandas to scrape the table containing facts about the planet including Diameter, Mass, etc.

  • Used Pandas to convert the data to a HTML table string.

Mars Hemispheres

  • Visited the USGS Astrogeology site here to obtain high resolution images for each of Mar's hemispheres.

  • Saved the image url string for the full resolution hemisphere image and the Hemisphere title containing the hemisphere name. Used a Python dictionary to store the data using the keys img_url and title.

  • Appended the dictionary with the image url string and the hemisphere title to a list. The list contains one dictionary for each hemisphere.

Step 2 - MongoDB and Flask Application

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

  • Started by converting my Jupyter notebook into a Python script called scrape_mars.py with a function called scrape that executes all of the scraping code from above and returns one Python dictionary containing all of the scraped data.

  • Next, created a route called /scrape that imports the scrape_mars.py script and called the scrape function.

    • Stored the return value in Mongo as a Python dictionary.
  • Created a root route / that queries the Mongo database and passes the Mars data into an HTML template to display the data.

  • Created a template HTML file called index.html that takes the mars data dictionary and displays all of the data in the appropriate HTML elements.

About

This project scrapes the web to build an application for Mission to Mars data. Demonstrates use of Beautiful Soup, Pandas, Splinter, MongoDB, HTML, and CSS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published