<jupyter_start><jupyter_text>NASA Mars News<jupyter_code>#Dependencies
from splinter import Browser
from bs4 import BeautifulSoup as bs
import pandas as pd
#Set path and initialize chrome borwser 
executable_path = {'chromedriver.exe'}
browser = Browser('chrome', executable_path, headless=False)
#Visit url
url = 'https://mars.nasa.gov/news/'
browser.visit(url)
#Convert browser html to soup object
html = browser.html
news_soup = bs(html, 'html.parser')
#Create empty lists for titles and paragraphs
titles=[]
news_p=[]

#Assign titles to variable
title_search=news_soup.find_all('div', class_='content_title')
for title in title_search:
    titles.append(title.text.strip())

#Assign paragraphs to variable
p_search=news_soup.find_all('div', class_='article_teaser_body')
for p in p_search:
    news_p.append(p.text.strip())<jupyter_output><empty_output><jupyter_text>JPL Featured Image<jupyter_code>#Visit url
url_1 = 'https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars'
browser.visit(url_1)
#Find full size image
browser.click_link_by_partial_text('FULL IMAGE')
#Find full size image
browser.click_link_by_partial_text('more info')
#Convert browser html to soup object
html_1 = browser.html
pic_soup = bs(html_1, 'lxml')
#Find featued image url
results=pic_soup.find('figure', class_='lede')
featured_path=results.a['href']
featured_image_url='https://www.jpl.nasa.gov'+featured_path<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>#Enter url
url_2 = 'https://space-facts.com/mars/'
#Use pandas to scrape table
tables = pd.read_html(url_2)
#Select table and clean up
mars_df=tables[0]
mars_df.columns=["Description", 'Mars']
mars_df.set_index("Description", inplace=True)
#Covert table to html string
mars_df.to_html()<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>#Visit url
url_3 = 'https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars'
browser.visit(url_3)
#Convert browser html to soup object
html_3 = browser.html
hemi_soup = bs(html_3, 'html.parser')
#Create list of titles
image_titles=[]

titles=hemi_soup.find_all('img', class_="thumb")

for title in titles:
         image_title= title['alt']
         image_titles.append(image_title)

#Create list of image urls
image_urls=[]

links=hemi_soup.find_all('a', class_="itemLink product-item")

for link in links:
    if (link.img):
        # image_url= 'https://astrogeology.usgs.gov/' +link['href']
        image_urls.append(link.img)

#Loop through image_urls to find url for full size image 
full_image_urls=image_urls

# for url in image_urls:
#     browser.visit(url)

#     html_4 = browser.html
#     hemi_image_soup = bs(html_4, 'html.parser')

#     results = hemi_image_soup.find_all('img', class_='wide-image')
#     relative_img_path = results[0]['src']
#     link = 'https://astrogeology.usgs.gov/' + relative_img_path
#     full_image_urls.append(link)

#Create list of dictionaries
hemispheres=[]

mars_zip=zip(titles, full_image_urls)

# Iterate through the zipped object
for title, img in mars_zip:
    mars_dict = {}
    mars_dict['title'] = title
    mars_dict['img_url'] = img
    hemispheres.append(mars_dict)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12464942349641633, 'fraction_numerical': 0.005297600498597694, 'mean_word_length': 5.978260869565218, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 7, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '621315', 'license': 'MIT', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1165, 'n_words': 242, 'path': 'mission_to_mars.ipynb', 'repo_name': 'ahchambers/Web-Scraping', 'size': '3209'}