<jupyter_start><jupyter_text>Mars News<jupyter_code>executable_path = {'executable_path': ChromeDriverManager().install()}
browser = Browser('chrome', **executable_path, headless=False)
url = "https://redplanetscience.com/"
browser.visit(url)
html = browser.html
soup = BeautifulSoup(html, 'html.parser')
title = soup.title.text
title
news_title = soup.find('div', class_="content_title").text
print(news_title)
news_p = soup.find('div', class_='article_teaser_body').text
print(news_p)<jupyter_output>NASA spacecraft at Mars are going to be on their own for a few weeks when the Sun comes between Mars and Earth, interrupting communications.<jupyter_text>Mars Images<jupyter_code>image_url = "https://spaceimages-mars.com/"
browser.visit(image_url)
html_img = browser.html
soup = BeautifulSoup(html_img, 'html.parser')
for item in soup.find_all('img', class_="headerimage fade-in"):
    print(item['src'])
mars_pic=item['src']

main_url = 'https://spaceimages-mars.com/'

featured_image_url = main_url + mars_pic

featured_image_url<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>facts_url = "https://galaxyfacts-mars.com/"
browser.visit(facts_url)
table = pd.read_html(facts_url)
table[0]
facts_df=table[0]
facts_df.columns = ["Description","Mars","Earth"]
facts_df=facts_df.set_index(["Description"])
facts_df=facts_df.drop(["Mars - Earth Comparison"])
facts_df
facts_html = facts_df.to_html()
facts_html<jupyter_output><empty_output><jupyter_text>Mars Hemispheres Cerberus<jupyter_code>mars_hemispheres_urls= ("https://marshemispheres.com/")
cerberus_url = ("https://marshemispheres.com/cerberus.html")
response = requests.get(cerberus_url)
c_soup = BeautifulSoup(response.text, 'html.parser')
#c_soup
cerberus_soup = c_soup.find_all('div', class_="wide-image-wrapper")
print(cerberus_soup)
for img in cerberus_soup:
    pic = img.find('li')
    c_img = pic.find('a')['href']
cerberus_url=mars_hemispheres_urls + c_img
print(cerberus_url)<jupyter_output>https://marshemispheres.com/images/full.jpg<jupyter_text>Schiaparelli<jupyter_code>schiaparelli_url = ("https://marshemispheres.com/schiaparelli.html")
response = requests.get(schiaparelli_url)
s_soup = BeautifulSoup(response.text, 'html.parser')

schiaparelli_soup = s_soup.find_all('div', class_="wide-image-wrapper")

for img in schiaparelli_soup:
    pic = img.find('li')
    s_img = pic.find('a')['href']
schiaparelli_url=mars_hemispheres_urls + s_img
print(schiaparelli_url)<jupyter_output>https://marshemispheres.com/images/schiaparelli_enhanced-full.jpg<jupyter_text>Syrtis Major<jupyter_code>syrtis_url = ("https://marshemispheres.com/syrtis.html")
response = requests.get(syrtis_url)
syrtis_soup = BeautifulSoup(response.text, 'html.parser')

syrtis_soup = syrtis_soup.find_all('div', class_="wide-image-wrapper")

for img in syrtis_soup:
    pic = img.find('li')
    syrtis_img = pic.find('a')['href']
syrtis_url=mars_hemispheres_urls + syrtis_img
print(syrtis_url)<jupyter_output>https://marshemispheres.com/images/syrtis_major_enhanced-full.jpg<jupyter_text>Valles Marineris<jupyter_code>valles_url = ("https://marshemispheres.com/valles.html")
response = requests.get(valles_url)
valles_soup = BeautifulSoup(response.text, 'html.parser')

valles_soup = valles_soup.find_all('div', class_="wide-image-wrapper")

for img in valles_soup:
    pic = img.find('li')
    valles_img = pic.find('a')['href']
valles_url=mars_hemispheres_urls + valles_img
print(valles_url)
hemisphere_image_urls = [
    {"title": "Valles Marineris Hemisphere", "img_url": "valles_url"},
    {"title": "Cerberus Hemisphere", "img_url": "cerberus_url"},
    {"title": "Schiaparelli Hemisphere", "img_url": "schiparelli_url"},
    {"title": "Syrtis Major Hemisphere", "img_url": "syrtis_url"},
]

mars_dict = {
        "news_title": news_title,
        "news_paragraph": news_p,
        "featured_image": featured_image_url,
        "mars_facts": facts_html,
        "hemisphere_image": hemisphere_image_urls

}
conn = 'mongodb://localhost:27017'
client = pymongo.MongoClient(conn)
db = client.mars_db
collection = db.mars_dict
collection.insert_one(mars_dict)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14185934489402696, 'fraction_numerical': 0.0016859344894026974, 'mean_word_length': 7.223762376237624, 'pattern_counts': {'":': 13, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 12, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '425221', 'license': 'ADSL', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1603, 'n_words': 221, 'path': 'missions_to_mars.ipynb', 'repo_name': 'rachelverner/web-scraping-challenge', 'size': '4152'}