This is a small a web application that scrapes various websites for data related to the planet Mars and displays the information in a single HTML page.
Scraped using Jupyter Notebook, BeautifulSoup, Pandas, and Requests/Splinter.
- Scrape the NASA Mars News Site and collect the latest News Title and Paragraph Text.
-
Scraped the JPL Featured Space Image from here.
-
Made sure to find the image url to the full size
.jpg
image.
# Example:
featured_image_url = 'https://www.jpl.nasa.gov/spaceimages/images/largesize/PIA16225_hires.jpg'
- Using the Mars Weather twitter account here , scraped the latest Mars weather tweet from the page.
# 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'
-
From the Mars Facts webpage here, used Pandas to scrape the table containing facts about the planet including Diameter, Mass, etc.
-
Converted the data to a HTML table string.
-
Scraped the high resolution images for each of Mar's hemispheres from thebUSGS Astrogeology site here.
-
Assigned each image url string and hemisphere title to a dictionary and appended each dict. to a list.
# 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": "..."},
]
Created a HTML page with FLASK template to display all of the Mars information which I stored in a MongoDB.
-
Converted the Jupyter notebook into a Python script called
scrape_mars.py
with a function calledscrape
that will execute all of the scraping code and return a Python dictionary containing all of the data. -
Made a route called
/scrape
to import thescrape_mars.py
script and call thescrape
function.- Returns value in Mongo as a Python dictionary.
-
Root route
/
queries Mongo db then passes data into an HTML template for displaying. -
Created
index.html
to take the mars data dictionary and display all of the data in the appropriate HTML elements.