<jupyter_start><jupyter_text>Step 1 - Scraping<jupyter_code>from splinter import Browser
from bs4 import BeautifulSoup
import pandas as pd
import time
executable_path = {'executable_path': '/usr/local/bin/chromedriver'}
browser = Browser('chrome', **executable_path, headless=False)<jupyter_output><empty_output><jupyter_text>NASA Mars News<jupyter_code>url_NASA_Mars_News = "https://mars.nasa.gov/news/"
browser.visit(url_NASA_Mars_News)
time.sleep(1)
html = browser.html
soup = BeautifulSoup(html,'html.parser')
heading_list = []

for heading in soup.find_all('div',class_="content_title"):
    heading_list.append(heading.find('a').text)
details_list = []

for details in soup.find_all('div',class_="article_teaser_body"):
    details_list.append(details.text)
news_title = heading_list[0]
news_p = details_list[0]
news_dict = {"Headline": news_title,"Details": news_p}
news_dict['Headline']
print("Title:", news_title)
print('-'*117)
print("Latest News Information:",news_p)<jupyter_output>Title: Mars Scientists Investigate Ancient Life in Australia
---------------------------------------------------------------------------------------------------------------------
Latest News Information: Teams with NASA's Mars 2020 and ESA's ExoMars practiced hunting for fossilized microbial life in the Australian Outback in preparation for their Red Planet missions.<jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>url_JPL_Mars_Space_Images = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(url_JPL_Mars_Space_Images)
time.sleep(1)
html = browser.html
soup = BeautifulSoup(html,'html.parser')
featured_image_list = []

for image in soup.find_all('div',class_="img"):
    featured_image_list.append(image.find('img').get('src'))
feature_image = featured_image_list[19]
feature_image_url = "https://www.jpl.nasa.gov/" + feature_image
feature_image_dict = {"image": feature_image_url}

print("Feature Image URL:", feature_image_url)<jupyter_output>Feature Image URL: https://www.jpl.nasa.gov//spaceimages/images/wallpaper/PIA23529-640x350.jpg<jupyter_text>Mars Weather<jupyter_code>url_Mars_Weather = "https://twitter.com/marswxreport?lang=en"
browser.visit(url_Mars_Weather)
time.sleep(1)
html = browser.html
soup = BeautifulSoup(html,'html.parser')
weather_info_list = []

for weather_info in soup.find_all('p',class_="TweetTextSize"):
    weather_info_list.append(weather_info.text)
mars_weather = weather_info_list[0]
mars_weather_dict = {"mar_weather": mars_weather }

print('Latest Mars Weather:',mars_weather)<jupyter_output>Latest Mars Weather: InSight sol 348 (2019-11-19) low -102.5ºC (-152.5ºF) high -23.2ºC (-9.8ºF)
winds from the SSE at 5.1 m/s (11.5 mph) gusting to 18.9 m/s (42.3 mph)
pressure at 6.80 hPapic.twitter.com/iZwojPj9au<jupyter_text>Mars Facts<jupyter_code>url = 'https://space-facts.com/mars/'

tables = pd.read_html(url)
tables
df = tables[0]
df.head(8)
df = df.rename(columns={0: "", 1: ""})
df
df.columns = ["Description", "Values"]
df.set_index(["Description"])
df
df_Mars_Facts = df.to_html("df_Mars_Facts_Table.html",index=False)<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>url_Mars_Hemisperes = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
browser.visit(url_Mars_Hemisperes)
html = browser.html
soup = BeautifulSoup(html,'html.parser')
title_list = []

for title in soup.find_all('div',class_="description"):
    title_list.append(title.find('h3').text)
title_list
hemisphere_image_url = []

for image in soup.find_all('div',class_="item"):
    url = "https://astrogeology.usgs.gov/"
    hemisphere_image_url.append(url + image.find('img').get('src'))
hemisphere_image_url
full_image_url = []

for each_url in hemisphere_image_url:
    split_url = each_url.split(".tif_thumb.png")[0]
    image_url = split_url + ".tif/full.jpg"
    full_image_url.append(image_url)
full_image_url
hemisphere_image_urls = [
    {"title": "Valles Marineris Hemisphere", "img_url": full_image_url[3]},
    {"title": "Cerberus Hemisphere", "img_url": full_image_url[0]},
    {"title": "Schiaparelli Hemisphere", "img_url": full_image_url[1]},
    {"title": "Syrtis Major Hemisphere", "img_url": full_image_url[2]},]
image_one = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/cerberus_enhanced.tif/full.jpg'
image_two = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/schiaparelli_enhanced.tif/full.jpg'
image_three = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/syrtis_major_enhanced.tif/full.jpg'
image_four = 'https://astropedia.astrogeology.usgs.gov/download/Mars/Viking/valles_marineris_enhanced.tif/full.jpg'

full_image = {"image_one": image_one, "image_two":image_two, "image_three":image_three, "image_four":image_four}
full_image['image_one']
full_image['image_two']
full_image['image_three']
full_image['image_four']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16291336985189694, 'fraction_numerical': 0.01602759180361128, 'mean_word_length': 6.042857142857143, 'pattern_counts': {'":': 16, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 12, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '254156', 'license': 'ADSL', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1789, 'n_words': 276, 'path': 'Mission_to_Mars/mission_to_mars.ipynb', 'repo_name': 'RomaPatel7/web-scraping-challenge', 'size': '4929'}