<jupyter_start><jupyter_text>NASA Mars News<jupyter_code>#Visit URL
url = 'https://redplanetscience.com/'
browser.visit(url)
#HTML Object
html = browser.html

#Parse with beatiful soup
soup = bs(html, 'html.parser')
#collect the latest News Title and Paragraph Text
news_title = soup.find_all('div', class_='content_title')[0].text
news_p = soup.find_all('div', class_='article_teaser_body')[0].text

#Display scraped data 
print(news_title)
print("-----------------------------------------------")
print(news_p)<jupyter_output>NASA's Curiosity Mars Rover Takes a New Selfie Before Record Climb
-----------------------------------------------
Along with capturing an image before its steepest ascent ever, the robotic explorer filmed its "selfie stick," or robotic arm, in action.<jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>#Visit URL
image_url = 'https://spaceimages-mars.com'
browser.visit(image_url)
#HTML Object
image_html = browser.html

#Parse with beautiful soup
image_soup =  bs(image_html, 'html.parser')
#Find image url full size
image_path = image_soup.find_all('img')[3]["src"]

#Find image link
featured_image_url = image_url + image_path
print(featured_image_url)<jupyter_output>https://spaceimages-mars.comimage/mars/Proctor Crater Dunes 7.jpg<jupyter_text>Mars Facts<jupyter_code>#Visit URL
facts_url = 'https://galaxyfacts-mars.com'
browser.visit(facts_url)
#Use Pandas to scrape the table containing facts about the planet
table = pd.read_html(facts_url)
table
#Create dataframe
facts_df = table[0]
facts_df
mars_facts_df = facts_df.drop(labels=0, axis=0)
mars_facts_df
mars_facts_df.columns = ['Description','Mars', 'Earth']
mars_facts_df
#convert the data to a HTML table string
mars_facts_html = mars_facts_df.to_html()
print(mars_facts_html)<jupyter_output><table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Description</th>
      <th>Mars</th>
      <th>Earth</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>Diameter:</td>
      <td>6,779 km</td>
      <td>12,742 km</td>
    </tr>
    <tr>
      <th>2</th>
      <td>Mass:</td>
      <td>6.39 × 10^23 kg</td>
      <td>5.97 × 10^24 kg</td>
    </tr>
    <tr>
      <th>3</th>
      <td>Moons:</td>
      <td>2</td>
      <td>1</td>
    </tr>
    <tr>
      <th>4</th>
      <td>Distance from Sun:</td>
      <td>227,943,824 km</td>
      <td>149,598,262 km</td>
    </tr>
    <tr>
      <th>5</th>
      <td>Length of Year:</td>
      <td>687 Earth days</td>
      <td>365.24 days</td>
    </tr>
    <tr>
      <th>6</th>
      <td>Temperature:</td>
      <td>-87 to -5 °C</td>
      <td>-88 to 58°C</td>
    </tr>
  </tbody>
</table><jupyter_text>Mars Hemispheres<jupyter_code>#Visit URL
astro_url = 'https://marshemispheres.com/'
browser.visit(astro_url)
#HTML Object
hemisphere_html = browser.html

#Parse with beautiful soup
hemisphere_soup = bs(hemisphere_html, 'html.parser')
#Retrieve all items
hemispheres = hemisphere_soup.find_all('div', class_='item')

# #Create empty list
hemisphere_img_urls = []

# # #Main URL for loop
hemi_url = 'https://marshemispheres.com/'

for i in hemispheres:
    title = i.find('h3').text
    hemispheres_img = i.find('a', class_='itemLink product-item')['href']

# Visit full image website link
    browser.visit(hemi_url + hemispheres_img)

# HTML Object
    hemi_img_html = browser.html
    hemi_info = bs(hemi_img_html, 'html.parser')

# Create full image url
    img_url = hemi_url + hemi_info.find('img', class_='wide-image')['src']
    hemisphere_img_urls.append({'title' : title, 'img_url' : img_url})

print(hemisphere_img_urls)<jupyter_output>[{'title': 'Cerberus Hemisphere Enhanced', 'img_url': 'https://marshemispheres.com/images/f5e372a36edfa389625da6d0cc25d905_cerberus_enhanced.tif_full.jpg'}, {'title': 'Schiaparelli Hemisphere Enhanced', 'img_url': 'https://marshemispheres.com/images/3778f7b43bbbc89d6e3cfabb3613ba93_schiaparelli_enhanced.tif_full.jpg'}, {'title': 'Syrtis Major Hemisphere Enhanced', 'img_url': 'https://marshemispheres.com/images/555e6403a6ddd7ba16ddb0e471cadcf7_syrtis_major_enhanced.tif_full.jpg'}, {'title': 'Valles Marineris Hemisphere Enhanced', 'img_url': 'https://marshemispheres.com/images/b3c7c6c9138f57b4756be9b9c43e3a48_valles_marineris_enhanced.tif_full.jpg'}]
{'fraction_non_alphanumeric': 0.16570372082274093, 'fraction_numerical': 0.03351051536861567, 'mean_word_length': 4.0442890442890445, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 89, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '377005', 'license': 'ADSL', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1646, 'n_words': 317, 'path': 'mission_to_mars.ipynb', 'repo_name': 'Jordan-0618/web-scraping-challenge', 'size': '4327'}