<jupyter_start><jupyter_text>NASA Mars News<jupyter_code>mission_to_mars ={}

executable_path = {'executable_path': '/usr/local/bin/chromedriver'}
browser = Browser('chrome', **executable_path, headless=False)

url = 'https://mars.nasa.gov/news/'
browser.visit(url)
time.sleep(1)
news_html = browser.html
# response = requests.get(url)
soup = BeautifulSoup(news_html, 'html.parser')
# results are returned as an iterable list
results = soup.find('div', class_="slide")
news_title = results.find('div', class_="content_title").text
news_p = results.find('div',class_="rollover_description_inner").text
# print(f"Title: {news_title}")
# print(f"Description: {news_p}")
mission_to_mars['news_title'] = news_title
mission_to_mars['news_description'] = news_p<jupyter_output><empty_output><jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>executable_path = {'executable_path': '/usr/local/bin/chromedriver'}
browser = Browser('chrome', **executable_path, headless=False)

url = 'https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars'
browser.visit(url)

time.sleep(1)
browser.click_link_by_partial_text('FULL IMAGE')

# html = browser.html
# featured_image_soup = BeautifulSoup(html,'html.parser')

# buttons = featured_image_soup.find('div', class_='addthis_toolbox')
# more_info_button = buttons.find.a['button'].text
# more_info_button


time.sleep(1)


# Find "More Info" Button and Click It
browser.is_element_present_by_text("more info", wait_time=1)
more_info_element = browser.find_link_by_partial_text("more info")
more_info_element.click()

time.sleep(1)
html = browser.html
featured_image_soup = BeautifulSoup(html,'html.parser')
# print(featured_image_soup.prettify())

figure = featured_image_soup.find('figure', class_="lede")
featured_image_url = figure.img['src']
featured_image_url = f"https://www.jpl.nasa.gov{featured_image_url}"
# print(featured_image_url)
mission_to_mars['featured_image_url'] = featured_image_url

buttons = featured_image_soup.find_by_css('a.button')
# more_info_button = buttons.find_all('a')
buttons<jupyter_output><empty_output><jupyter_text>Mars Weather<jupyter_code>url =  'https://twitter.com/marswxreport?lang=en'
browser.visit(url)
time.sleep(1)
twitter_html = browser.html
twitter_soup = BeautifulSoup(twitter_html,'html.parser')
# print(twitter_soup.prettify())

tweets = twitter_soup.find('div', class_='js-tweet-text-container')
mars_weather = tweets.find('p', class_="tweet-text").text
# mars_weather
mission_to_mars['mars_weather'] = mars_weather<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>url = 'https://space-facts.com/mars/'
browser.visit(url)
time.sleep(1)

tables = pd.read_html(url)
mars_facts_df = tables[1]
mars_facts_df.columns=['Mars','Facts']
# mars_facts_df
mission_to_mars['mars_facts_df'] = mars_facts_df<jupyter_output><empty_output><jupyter_text>Mars Hemisphers<jupyter_code>executable_path = {'executable_path': '/usr/local/bin/chromedriver'}
browser = Browser('chrome', **executable_path, headless=False)

url =  'https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars'
browser.visit(url)
time.sleep(1)
#



hem_html = browser.html
hem_soup = BeautifulSoup(hem_html,'html.parser')

hems_dict =[]
hems = hem_soup.find_all('div', class_='item')


######

# hems


# hem_url = hems[0].a['href']

# # hem_url
# browser.visit('https://astrogeology.usgs.gov' + hem_url[0])

# hem_img_html = browser.html
# hem_img_soup = BeautifulSoup(hem_img_html,'html.parser')
# hem_img_url = hem_img_soup.find('div', class_'wide_image)
# hem_img_url = hem_img_url.find('img', class_'wide_image)
# hem_img_url                                
                                


                                
                                
# # hem_img_url = hem_img_url[1].a['href']

# # hem_dict ={'title': hem_name, 'img_url': hem_img_url}
# # hems_dict.append(hem_dict)
# # browser.back()


#######




for hem in hems:
    
    time.sleep(1)
    hem_dict = {}

    hem_name = hem.find('h3').text
    hem_name = hem_name.split(' Enhanced')
    hem_name = hem_name[0]
    hem_url = hem.a['href']
    browser.visit('https://astrogeology.usgs.gov' + hem_url)
    
    hem_img_html = browser.html
    hem_img_soup = BeautifulSoup(hem_img_html,'html.parser')
    hem_img_url = hem_img_soup.find('a', text='Sample').get('href')
    
    hem_dict ={'title': hem_name, 'img_url': hem_img_url}
    hems_dict.append(hem_dict)
    browser.back()
    

# hems_dict
# hemisphere_image_urls
mission_to_mars['hemisphere_image_urls'] = hems_dict
browser.quit()

mission_to_mars<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14826839826839827, 'fraction_numerical': 0.00367965367965368, 'mean_word_length': 5.639367816091954, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, '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': '518869', 'license': 'ADSL', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1721, 'n_words': 219, 'path': 'MissionstoMars/mission_to_mars.ipynb', 'repo_name': 'buckbrutus2001/web-scraping-challenge', 'size': '4620'}