<jupyter_start><jupyter_text>Visit the NASA mars news site<jupyter_code># Visit the Mars news site
url = 'https://redplanetscience.com/'
browser.visit(url)

# Optional delay for loading the page--wait_time
browser.is_element_present_by_css('div.list_text', wait_time=1)
# Convert the browser html to a soup object
html = browser.html
news_soup = soup(html, 'html.parser')
# display the current title content
slide_elem = news_soup.select_one('div.list_text')
slide_elem
# Use the parent element to find the first a tag and save it as `news_title`
news_title = news_soup.find('div', class_='content_title').text
print(news_title)
# Use the parent element to find the paragraph text
news_parent = news_soup.find('div', class_='article_teaser_body').text
print(news_parent)<jupyter_output>NASA-JPL's coverage of the Mars InSight landing earns one of the two wins, making this the NASA center's second Emmy.<jupyter_text>JPL Space Images Featured Image<jupyter_code># Visit URL
url = 'https://spaceimages-mars.com'
browser.visit(url)
# Find and click the full image button
image_url = browser.find_by_tag('button')[1]
image_url.click()
# Parse the resulting html with soup
# get HTML object
html = browser.html
# use beautiful soup parser on HTML
image_soup = soup(html, 'html.parser')
image_soup
print(image_soup.prettify())
# find the relative image url
##thumbimg
img_url_rel = image_soup.find('img', class_='fancybox-image').get('src')
img_url_rel
# Use the base url to create an absolute url
img_url = f'https://spaceimages-mars.com/{img_url_rel}'
img_url<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code># Use `pd.read_html` to pull the data from the Mars-Earth Comparison section
# hint use index 0 to find the table
df = pd.read_html('https://galaxyfacts-mars.com/')[0]
df.head()
df.to_html()
df
df.to_html()<jupyter_output><empty_output><jupyter_text>Hemispheres<jupyter_code>url = 'https://marshemispheres.com/'

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

# Get a list of all of the hemispheres
links = browser.find_by_css('a.product-item img')

# Next, loop through those links, click the link, find the sample anchor, return the href
for i in range(len(links)):
    
    
    # We have to find the elements on each loop to avoid a stale element exception
    
    
    # Next, we find the Sample image anchor tag and extract the href
    
    
    # Get Hemisphere title
    
    
    # Append hemisphere object to list
    
    
    # Finally, we navigate backwards
    browser.back()
hemisphere_image_urls
browser.quit()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09775580068467098, 'fraction_numerical': 0.0015214910612400153, 'mean_word_length': 4.963718820861678, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '668126', 'license': 'ADSL', 'n_tokens_mistral': 879, 'n_tokens_neox': 863, 'n_words': 267, 'path': 'Instructions/.ipynb_checkpoints/Mission_to_Mars-Starter-checkpoint.ipynb', 'repo_name': 'jcus/web-scraping-challenge', 'size': '2629'}