<jupyter_start><jupyter_text>Mac Users<jupyter_code># Show path that we will be using
# https://splinter.readthedocs.io/en/latest/drivers/chrome.html
!which chromedriver<jupyter_output>/usr/local/bin/chromedriver<jupyter_text>NASA Mars News<jupyter_code># Choose the executable path to driver
executable_path = {"executable_path": "/usr/local/bin/chromedriver"}
browser = Browser("chrome", **executable_path, headless=False)
# Visit Nasa news url through splinter module
url_news = "https://mars.nasa.gov/news/"
browser.visit(url_news)
# HTML Object
html_news = browser.html
soup = bs(html_news, "html.parser")

# Scrape the latest News Title and Paragraph Text
news_title = soup.find("div", class_ = "content_title").text
news_paragraph = soup.find("div", class_ = "article_teaser_body").text

# Display scrapped news 
print(news_title)
print("-----------------------------------------")
print(news_paragraph)<jupyter_output>Nine Finalists Chosen in NASA's Mars 2020 Rover Naming Contest
-----------------------------------------
Nine finalists have been chosen in the essay contest for K-12 students across U.S. to name NASA's next Mars rover. Now you can help by voting for your favorite.<jupyter_text>________________________________________________________________________   JPL Mars Space Images - Featured Image<jupyter_code># Visit JPL Featured Space Image url through splinter module
url_spaceimage = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(url_spaceimage)
# HTML Object
img_html = browser.html
img_soup = bs(img_html, "html.parser")
# Find image url to the full size
featured_image = img_soup.find("article")["style"].replace('background-image: url(','').replace(');', '')[1:-1]

# Display url of the full image
featured_image_url = f"https://www.jpl.nasa.gov{featured_image}"
print("JPL Featured Space Image")
print("-----------------------------------------")
print(featured_image_url)<jupyter_output>JPL Featured Space Image
-----------------------------------------
https://www.jpl.nasa.gov/spaceimages/images/wallpaper/PIA15254-1920x1200.jpg<jupyter_text>________________________________________________________________________  Mars Weather<jupyter_code># Visit Mars Weather twitter through splinter
url_weather = "https://twitter.com/marswxreport?lang=en"
browser.visit(url_weather)

# HTML Object
weather_html = browser.html
weather_soup = bs(weather_html, "html.parser")
# HTML Object
weather_html = browser.html
weather_soup = bs(weather_html, "html.parser")
# Scrape the latest Mars weather tweet from the page
weather = weather_soup.find("p", class_="TweetTextSize TweetTextSize--normal js-tweet-text tweet-text")

# Remove the anchor from paragraph
weather.a.decompose()
weather = weather.text
# Clean up the text
mars_weather = weather.replace(" \n", '')

# Display Mars Weather
print("Mars Weather")
print("-----------------------------------------")
print(mars_weather)<jupyter_output>Mars Weather
-----------------------------------------
InSight sol 415 (2020-01-27) low -95.1ºC (-139.1ºF) high -14.3ºC (6.3ºF)
winds from the W at 5.1 m/s (11.4 mph) gusting to 20.7 m/s (46.4 mph)
pressure at 6.30 hPa<jupyter_text>________________________________________________________________________  Mars Facts<jupyter_code># Visit the Mars Facts webpage and use Pandas to scrape the table
url_facts = "https://space-facts.com/mars/"

# Use Pandas - read_html - to scrape tabular data from a page
mars_facts = pd.read_html(url_facts)
mars_facts
mars_df = mars_facts[0]

# Create Data Frame
mars_df.columns = ["Description", "Value"]

# Set index to Description
mars_df.set_index("Description", inplace=True)

# Print Data Frame
mars_df
# Save html code to folder Assets
html_table = mars_df.to_html()

# Strip unwanted newlines to clean up the table
html_table.replace("\n", '')

# Save html code
mars_df.to_html("mars_facts_data.html")<jupyter_output><empty_output><jupyter_text>________________________________________________________________________  Mars Hemispheres<jupyter_code># Visit the USGS Astrogeology Science Center url through splinter
url_hemisphere = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
browser.visit(url_hemisphere)
# HTML Object
html_hemisphere = browser.html
soup = bs(html_hemisphere, "html.parser")
# Scrape all items that contain mars hemispheres information
hemispheres = soup.find_all("div", class_="item")

# Create empty list
hemispheres_info = []

# Sign main url for loop
hemispheres_url = "https://astrogeology.usgs.gov"

# Loop through the list of all hemispheres information
for i in hemispheres:
    title = i.find("h3").text
    hemispheres_img = i.find("a", class_="itemLink product-item")["href"]
    
    # Visit the link that contains the full image website 
    browser.visit(hemispheres_url + hemispheres_img)
    
    # HTML Object
    image_html = browser.html
    web_info = bs(image_html, "html.parser")
    
    # Create full image url
    img_url = hemispheres_url + web_info.find("img", class_="wide-image")["src"]
    
    hemispheres_info.append({"title" : title, "img_url" : img_url})

# Display titles and images ulr
#hemispheres_info

# Or Display titles and images ulr this way
    print("")
    print(title)
    print(img_url)
    print("-----------------------------------------")<jupyter_output>Cerberus Hemisphere Enhanced
https://astrogeology.usgs.gov/cache/images/cfa62af2557222a02478f1fcd781d445_cerberus_enhanced.tif_full.jpg
-----------------------------------------

Schiaparelli Hemisphere Enhanced
https://astrogeology.usgs.gov/cache/images/3cdd1cbf5e0813bba925c9030d13b62e_schiaparelli_enhanced.tif_full.jpg
-----------------------------------------

Syrtis Major Hemisphere Enhanced
https://astrogeology.usgs.gov/cache/images/ae209b4e408bb6c3e67b6af38168cf28_syrtis_major_enhanced.tif_full.jpg
-----------------------------------------

Valles Marineris Hemisphere Enhanced
https://astrogeology.usgs.gov/cache/images/7cf2da4bf549ed01c17f206327be4db7_valles_marineris_enhanced.tif_full.jpg
-----------------------------------------
{'fraction_non_alphanumeric': 0.170327868852459, 'fraction_numerical': 0.02262295081967213, 'mean_word_length': 3.830562153602534, 'pattern_counts': {'":': 1, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 13, 'lorem ipsum': 0, 'www.': 3, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '489597', 'license': 'ADSL', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1880, 'n_words': 444, 'path': 'mission_to_mars.ipynb', 'repo_name': 'surasb11/mission-to-mars', 'size': '6100'}