<jupyter_start><jupyter_text>Featured Image<jupyter_code># Visit URL
url = 'https://spaceimages-mars.com'
browser.visit(url)
# Find and click the full image button
full_image_elem = browser.find_by_tag('button')[1]
full_image_elem.click()
# Parse the resulting html with soup
html = browser.html
img_soup = soup(html, 'html.parser')
img_soup
# find the relative image url
img_url_rel = img_soup.find('img', class_='fancybox-image').get('src')
img_url_rel
# Use the base url to create an absolute url
featured_img_url = f'https://spaceimages-mars.com/{img_url_rel}'
featured_img_url<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>df = pd.read_html('https://galaxyfacts-mars.com')[0]
df.head()
df.columns=['Description', 'Mars', 'Earth']
df.set_index('Description', inplace=True)
df
html_table = df.to_html()
html_table = html_table.replace('\n', '')
html_table<jupyter_output><empty_output><jupyter_text>Hemispheres<jupyter_code>url = 'https://marshemispheres.com/'

browser.visit(url)
# 2. Create a list to hold the images and titles.
hemisphere_image_urls = []

# 3. Write code to retrieve the image urls and titles for each hemisphere.
for hemis in range(4):
    # Browse through each article
    browser.links.find_by_partial_text('Hemisphere')[hemis].click()
    
    # Parse the HTML
    html = browser.html
    hemi_soup = soup(html,'html.parser')
    
    # Scraping
    title = hemi_soup.find('h2', class_='title').text
    img_url = hemi_soup.find('li').a.get('href')
    
    # Store findings into a dictionary and append to list
    hemispheres = {}
    hemispheres['img_url'] = f'https://marshemispheres.com/{img_url}'
    hemispheres['title'] = title
    hemisphere_image_urls.append(hemispheres)
    
    # Browse back to repeat
    browser.back()

# Quit browser
browser.quit()
hemisphere_image_urls
# Code courtesy of 'JW99' from Github.com, 'nicoserrano' from Github.com, 'amylio' from Github.com<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12888436067244013, 'fraction_numerical': 0.004075394803871625, 'mean_word_length': 5.099378881987578, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 5, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '590637', 'license': 'ADSL', 'n_tokens_mistral': 720, 'n_tokens_neox': 706, 'n_words': 148, 'path': 'Mission_to_mars/mission_to_mars.ipynb', 'repo_name': 'bso613/web-scraping-challenge', 'size': '1963'}