<jupyter_start><jupyter_text>Mission to MarsWeb application that scrapes various websites for data related to the Mission to Mars<jupyter_code>import pandas as pd
from splinter import Browser
from bs4 import BeautifulSoup
import requests
import os
#NASA Mars News
executable_path = {'executable_path': 'chromedriver.exe'}
browser = Browser('chrome', **executable_path, headless=False)
#Scrape the Nasa News
url_nasa_news = "https://mars.nasa.gov/news/"
browser.visit(url_nasa_news)
#Save News title and paragraph
html = browser.html
soup = BeautifulSoup(html, 'html.parser')
#first class with content_title was giving "Mars now"
news_title = soup.find_all("div", class_= "content_title")[1].text
news_p = soup.find("div", class_= "article_teaser_body").text

print(news_title)
print(news_p)
#JPL Mars Space Images - Featured Image
url_mars_image = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(url_mars_image)
browser.click_link_by_partial_text('FULL IMAGE')
browser.click_link_by_partial_text('more info')
html=browser.html
soup = BeautifulSoup(html, 'html.parser')
image_page = soup.find("figure", class_="lede")
image_url = image_page.find("a")["href"]
featured_image_url =f"https://www.jpl.nasa.gov{image_url}"
print(featured_image_url)
# Mars Weather
url_mars_weather = "https://twitter.com/marswxreport?lang=en"
response = requests.get(url_mars_weather)
soup = BeautifulSoup(response.text, 'html.parser')
#print(soup)
mars_weather = soup.find("p", class_= "TweetTextSize TweetTextSize--normal js-tweet-text tweet-text").text
print(mars_weather)
# Mars Facts
url_mars_facts = "https://space-facts.com/mars/"
mars_facts = pd.read_html(url_mars_facts)
mars_facts_df = pd.DataFrame(mars_facts[0])
mars_facts_df.rename(columns={0:"Mars Facts", 1:"Value"})

#store html table
html_table = mars_facts_df.to_html()
html_table.replace("\n", "")
print(html_table)

#save df as html file
mars_facts_df.to_html("mars_facts.html")
# Mars Hemispheres
mars_hemispheres_url = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
hemispheres_response = requests.get(mars_hemispheres_url)
soup = BeautifulSoup(hemispheres_response.text, 'html.parser')

#image data
image_data = soup.find_all("div", class_="item")

#hemisphere dictionary
hemisphere_image_urls = []
for image in image_data:
    image_title = image.find("h3").text
    image_url = image.find("a", class_="itemLink product-item")['href']
    full_image_url = f'https://astrogeology.usgs.gov{image_url}'
    
    # find image src
    image_response = requests.get(full_image_url)
    image_soup = BeautifulSoup(image_response.text, 'html.parser')
    image_src = image_soup.find('img', class_="wide-image")["src"]
    img_src_url = f'https://astrogeology.usgs.gov{image_src}'
    
    #add image title and source url to hemisphere dictionary
    hemisphere_image_urls.append({"title":image_title, "img_url": img_src_url })
  
print(hemisphere_image_urls)<jupyter_output>[{'title': 'Cerberus Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/cfa62af2557222a02478f1fcd781d445_cerberus_enhanced.tif_full.jpg'}, {'title': 'Schiaparelli Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/3cdd1cbf5e0813bba925c9030d13b62e_schiaparelli_enhanced.tif_full.jpg'}, {'title': 'Syrtis Major Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/ae209b4e408bb6c3e67b6af38168cf28_syrtis_major_enhanced.tif_full.jpg'}, {'title': 'Valles Marineris Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/7cf2da4bf549ed01c17f206327be4db7_valles_marineris_enhanced.tif_full.jpg'}]
{'fraction_non_alphanumeric': 0.13177239313912334, 'fraction_numerical': 0.022869588891913966, 'mean_word_length': 7.237668161434978, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '344227', 'license': 'ADSL', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1340, 'n_words': 223, 'path': 'Missions_to_Mars/.ipynb_checkpoints/mission_to_mars-checkpoint.ipynb', 'repo_name': 'rbhansali07/web-scraping-challenge', 'size': '3673'}