<jupyter_start><jupyter_text>NASA Mars News<jupyter_code>executable_path = {'executable_path': ChromeDriverManager().install()}
browser = Browser('chrome', **executable_path, headless=False)
url = 'http://redplanetscience.com/'
browser.visit(url)
# HTML object
html = browser.html
# Parse HTML with Beautiful Soup
soup = BeautifulSoup(html, 'html.parser')

# Retrieve the latest news title and paragraph
news_title = soup.find_all('div', class_='content_title')[0].text
news_p = soup.find_all('div', class_='article_teaser_body')[0].text

# Use Beautiful Soup's find() method to navigate and retrieve attributes

print(f'Title: {news_title}')
print('-----------')
print(f'Para: {news_p}')<jupyter_output>Title: NASA's MAVEN Maps Winds in the Martian Upper Atmosphere that Mirror the Terrain Below and Gives Clues to Martian Climate
-----------
Para: Researchers have created the first map of wind circulation in the upper atmosphere of a planet besides Earth, using data from NASA’s MAVEN spacecraft that were collected during the last two years.<jupyter_text>JPL Mars Space Images<jupyter_code># Mars Image to be scraped
img_url = 'http://spaceimages-mars.com'
featured_image_url = 'http://spaceimages-mars.com/image/featured/mars3.jpg'
browser.visit(featured_image_url)

# HTML object
html = browser.html
# Parse HTML
featured_image_soup = BeautifulSoup(html, 'html.parser')
# Retrieve featured image link
relative_image_path = featured_image_soup.find_all('img')[0]["src"]
featured_image = relative_image_path
print(featured_image)<jupyter_output>https://spaceimages-mars.com/image/featured/mars3.jpg<jupyter_text>Mars Facts<jupyter_code>url = 'https://galaxyfacts-mars.com'
tables = pd.read_html(url)
tables
df = tables[0]
new_header = df.iloc[0] #grab the first row for the header
df = df[1:] #take the data less the header row
df.columns = new_header #set the header row as the df header

df.rename(columns = {'Mars - Earth Comparison':'Description'}, inplace = True)
df.head()
html_table = df.to_html()
html_table.replace('\n', '')
print(html_table)<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># Mars Image to be scraped
img_url = 'http://marshemispheres.com/'
featured_image_url = 'https://marshemispheres.com/images/39d3266553462198bd2fbc4d18fbed17_cerberus_enhanced.tif_thumb.png'
browser.visit(img_url)

# HTML object
html = browser.html
# Parse HTML
soup = BeautifulSoup(html, 'html.parser')
relative_image_paths = soup.find_all('img', class_='thumb')
titles = soup.find_all('div', class_='description')
# featured_image = relative_image_path

hemisphere_image_urls=[]

for x in range(len(relative_image_paths)):
    hemisphere_image_urls.append({ "tile": titles[x].h3.text,"img_ulr":relative_image_paths[x]['src']})

print(hemisphere_image_urls)<jupyter_output>[{'tile': 'Cerberus Hemisphere Enhanced', 'img_ulr': 'images/39d3266553462198bd2fbc4d18fbed17_cerberus_enhanced.tif_thumb.png'}, {'tile': 'Schiaparelli Hemisphere Enhanced', 'img_ulr': 'images/08eac6e22c07fb1fe72223a79252de20_schiaparelli_enhanced.tif_thumb.png'}, {'tile': 'Syrtis Major Hemisphere Enhanced', 'img_ulr': 'images/55a0a1e2796313fdeafb17c35925e8ac_syrtis_major_enhanced.tif_thumb.png'}, {'tile': 'Valles Marineris Hemisphere Enhanced', 'img_ulr': 'images/4e59980c1c57f89c680c0e1ccabbeff1_valles_marineris_enhanced.tif_thumb.png'}]<jupyter_text>Mars Dictionary<jupyter_code>mars_dict = {
        'Title': news_title,
        "Para": news_p,
        "mars_facts":html_table,
        "featured_Image": featured_image,
        "hemisphere_images": hemisphere_image_urls
    }
mars_dict
browser.quit()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1502202643171806, 'fraction_numerical': 0.03788546255506608, 'mean_word_length': 4.592364532019705, 'pattern_counts': {'":': 6, '<': 93, '<?xml version=': 0, '>': 93, 'https://': 3, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '240484', 'license': 'ADSL', 'n_tokens_mistral': 1825, 'n_tokens_neox': 1701, 'n_words': 329, 'path': 'Missions_to_Mars/mission_to_mars.ipynb', 'repo_name': 'SaradhaRam/web-scraping-challenge', 'size': '4540'}