<jupyter_start><jupyter_text>NASA Mars News<jupyter_code>#may need to run multiple times. Sometimes doesn't work on the first try. 

news_url = "https://mars.nasa.gov/news/"
browser.visit(news_url)

# Scrape page into Soup
html = browser.html
news_soup = bs(html, "html.parser")

#Get the latest news title
news_t = news_soup.find('div', class_='list_text')

news_title = news_t.find('div', class_='content_title').text

#get the latest paragraph text
news_p = news_t.find('div', class_='article_teaser_body').text



print("News Title:")
print(" ")
print(news_title)
print("-------------------------------------------------------------------------")
print("News Paragraph Text:")
print(" ")
print(news_p)<jupyter_output>News Title:
 
8 Martian Postcards to Celebrate Curiosity's Landing Anniversary
-------------------------------------------------------------------------
News Paragraph Text:
 
The NASA rover touched down eight years ago, on Aug. 5, 2012, and will soon be joined by a second rover, Perseverance.<jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>image_url = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(image_url)

# Scrape page into Soup
html = browser.html
image_soup = bs(html, "html.parser")

#find where the url is located
carousel = image_soup.find('article', class_='carousel_item')
#print(carousel.prettify())


img_url = carousel["style"]
#print(img_url)

#take out crap
img_url_nocrap = img_url.split("'")
#print(img_url_nocrap)

img_url_nocrap_real = img_url_nocrap[1]
#print(img_url_nocrap_real)

featured_image_url = f'https://www.jpl.nasa.gov{img_url_nocrap_real}'

print("Image's URL Path From Scraping:")
print(" ")
print(img_url_nocrap_real)
print("---------------------------------------------------------------")
print("Image's Full URL:")
print(" ")
print(featured_image_url)<jupyter_output>Image's URL Path From Scraping:
 
/spaceimages/images/wallpaper/PIA17841-1920x1200.jpg
---------------------------------------------------------------
Image's Full URL:
 
https://www.jpl.nasa.gov/spaceimages/images/wallpaper/PIA17841-1920x1200.jpg<jupyter_text>Mars Weather<jupyter_code>weather_url = "https://twitter.com/marswxreport?lang=en"
browser.visit(weather_url)

# Scrape page into Soup
html = browser.html
weather_soup = bs(html, "html.parser")

mars_weather = weather_soup.find_all('span', class_="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0")

#print("Latest Mars Weather Information:")
#print(" ")
#print(mars_weather)
tweet_list = []

for tweet in mars_weather:
    tweet_text = str(tweet.text)
    #if 'InSight sol' in tweet:
    if tweet_text.startswith('InSight sol'):
        tweet_list.append(tweet_text)
        #print(tweet_text)
        
print(tweet_list[0])
updated_mars_weather = tweet_list[0]
updated_mars_weather<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>facts_url = "https://space-facts.com/mars/"
browser.visit(facts_url)

# Scrape page into Soup
html = browser.html
#facts_soup = bs(html, "html.parser")

table = pd.read_html(facts_url)
table

mars_table = table[0]
mars_table
mars_table.columns = ["Description", "Value"]
mars_table

mars_table.set_index("Description", inplace=True)
mars_table
html_mars = mars_table.to_html()
html_mars
#cleaning up html
html_mars_cleaned = html_mars.replace('\n', '')
html_mars_cleaned<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>hemi_url = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
browser.visit(hemi_url)

# Scrape page into Soup
html = browser.html
hemi_soup = bs(html, "html.parser")

all_hemis = hemi_soup.find('div', class_='collapsible results')
#print(all_hemis)

ind_hemis = all_hemis.find_all('div', class_='item')
#print(ind_hemis)

hemis_urls = []

for hemi in ind_hemis:
    title = hemi.find('h3').text
    title = title.replace("Enhanced", "")
    
    url_path = hemi.find('a')['href']
    hemi_img_url = f'https://astrogeology.usgs.gov/{url_path}'
    browser.visit(hemi_img_url)
    
    html = browser.html
    new_hemi_soup = bs(html, "html.parser")
    
    download = new_hemi_soup.find('div', class_='downloads')
    image_url = download.find('a')['href']
    
    hemis_urls.append({"title": title, "img_url": image_url})
    
hemis_urls<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18969878132904117, 'fraction_numerical': 0.011956771671648655, 'mean_word_length': 4.017301038062284, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '287082', 'license': 'ADSL', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1566, 'n_words': 283, 'path': 'mission_to_mars.ipynb', 'repo_name': 'mhounsom/web-scraping-challenge', 'size': '4349'}