<jupyter_start><jupyter_text>Step 1 - Scraping NASA Mars News<jupyter_code># Import Dependencies
from bs4 import BeautifulSoup
import pandas as pd
import requests
import os
from splinter import Browser
# Setup/Import Splinter
executable_path = {'executable_path': 'chromedriver'}
browser = Browser('chrome', **executable_path, headless=False)
# Set URL PATH for latest Mars news
url_news = 'https://mars.nasa.gov/news/'
browser.visit(url_news)
# Configure initial BS and browser names
html = browser.html

soup = BeautifulSoup(html, 'html.parser')
# Create dictionary of latest news titles
news_titles_list = []
    
for news_titles in soup.find_all('div', class_='content_title'):
    news_titles_list.append(news_titles.find('a').text)
# Create dictionary of latest paragraphs
news_paragraph_list = []
    
for news_p in soup.find_all('div', class_='article_teaser_body'):
    news_paragraph_list.append(news_p.text)
# Test latest title at dict position 1
latest_news_title = news_titles_list[0]
latest_news_title
# Test latest paragraph at dict position 1
latest_paragraph_list = news_paragraph_list[0]
latest_paragraph_list<jupyter_output><empty_output><jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code># Set URL PATH for Jet Propulsion Labs featured image
url_featured = 'https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars'
browser.visit(url_featured)

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'))
featured_image = featured_image_list[0]

featured_image_url = 'https://www.jpl.nasa.gov/' + featured_image

featured_image_dictionary = {"image":featured_image_url}

print("Featured Image URL:", featured_image_url)<jupyter_output>Featured Image URL: https://www.jpl.nasa.gov//spaceimages/images/wallpaper/PIA22679-640x350.jpg<jupyter_text>Mars Weather<jupyter_code>url_weather = 'https://twitter.com/marswxreport?lang=en'
browser.visit(url_weather)

html = browser.html

soup = BeautifulSoup(html, 'html.parser')
mars_weather_list = []
for tweet in soup.find_all('p', class_='TweetTextSize TweetTextSize--normal js-tweet-text tweet-text'):
    mars_weather_list.append(tweet.text)
mars_weather = mars_weather_list[0]
print(mars_weather)<jupyter_output>Mars is hard

<NAME>'s Mars Exploration Family Portrait
http://www.planetary.org/blogs/jason-davis/updated-mars-exploration-family-portrait.html …pic.twitter.com/kCCusty5hw<jupyter_text>Mars Facts<jupyter_code>url_facts = 'https://space-facts.com/mars/'
tables = pd.read_html(url_facts)
tables
df_mars_facts = tables[0]
df_mars_facts.columns = ['Details', 'Measurements']
df_mars_facts.set_index('Details', inplace=False)
df_mars_facts
df_mars_table = df_mars_facts.to_html('mars_table.html')<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>url_hemis = 'https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars'
browser.visit(url_hemis)

html = browser.html

soup = BeautifulSoup(html, 'html.parser')
mars_hemi_titles = []
for h_titles in soup.find_all('div', class_='description'):
    mars_hemi_titles.append(h_titles.find('h3').text)
mars_hemi_images = []
for h_img in soup.find_all('div', class_='item'):
    url = 'https://astrogeology.usgs.gov/'
    mars_hemi_images.append(url+ image.find('img').get('src'))
mars_hemi_images
mars_hemi_big = []

for lg_img in mars_hemi_images:
    split_url = lg_img.split('.tif_thumb.png')[0]
    fixed_url = split_url + ".tif/full.jpg"
    mars_hemi_big.append(fixed_url)
mars_hemi_big
hemisphere_image_urls = [
    {"title": "Valles Marineris Hemisphere", "img_url": mars_hemi_big[3]},
    {"title": "Cerberus Hemisphere", "img_url": mars_hemi_big[0]},
    {"title": "Schiaparelli Hemisphere", "img_url": mars_hemi_big[1]},
    {"title": "Syrtis Major Hemisphere", "img_url": mars_hemi_big[2]},
]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12844500632111253, 'fraction_numerical': 0.0073324905183312266, 'mean_word_length': 6.849206349206349, 'pattern_counts': {'":': 9, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '534571', 'license': 'ADSL', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1445, 'n_words': 249, 'path': 'mission_to_mars.ipynb', 'repo_name': 'LukeArmstrongkc/Mission-to-Mars', 'size': '3960'}