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.
- Scraped the NASA Mars News Site and collected the latest News Title and Paragraph Text.
-
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.
- Visited the Mars Weather twitter account here and scraped the latest Mars weather tweet from the page.
-
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.
-
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
andtitle
. -
Appended the dictionary with the image url string and the hemisphere title to a list. The list contains one dictionary for each hemisphere.
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 calledscrape
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 thescrape_mars.py
script and called thescrape
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.