<jupyter_start><jupyter_text>Step 1 - Scraping<jupyter_code># Setting dependencies... 

!pip install webdriver_manager

from bs4 import BeautifulSoup as bs
from webdriver_manager.chrome import ChromeDriverManager
import pandas as pd
import requests
import os
from splinter import Browser<jupyter_output><empty_output><jupyter_text>NASA Mars News<jupyter_code>executable_path = {'executable_path': ChromeDriverManager().install()}
browser = Browser('chrome', **executable_path, headless=True)


nasa_mars_news = 'https://redplanetscience.com/'
browser.visit(nasa_mars_news)
nasa_mars_news_html = browser.html

nasa_mards_soup = bs(nasa_mars_news_html,'html.parser')
print(nasa_mards_soup.prettify())

mars_news_title = nasa_mards_soup.find('div',class_='content_title').text
mars_news_title
news_p = nasa_mards_soup.find('div', class_='article_teaser_body').text
news_p<jupyter_output><empty_output><jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>primary_url = "https://spaceimages-mars.com"

browser.visit(primary_url)
image_html = browser.html

soup_mars = bs(image_html, 'html.parser')

image = soup_mars.find('img', class_ = 'headerimage')
image
src = image["src"]
featured_image_url = "https://spaceimages-mars.com/" + src

print(featured_image_url)<jupyter_output>https://spaceimages-mars.com/image/featured/mars1.jpg<jupyter_text>Mars Facts<jupyter_code>url_mars_facts = 'https://galaxyfacts-mars.com'
table_1 = pd.read_html(url_mars_facts)
table_1
table_1_df = table_1[0]
table_1_df 
table_1_html = table_1_df.to_html()
table_1_html = table_1_html.replace('\n', '')
table_1_html<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>hem_url = "https://marshemispheres.com/"
browser.visit(hem_url)
html = browser.html

m_soup = bs(html, 'html.parser')

main_url = soup.find_all('div', class_='item')

 
titles = []

hemisphere_images_urls = []   
for each in main_url:
    title = each.find('h3').text
    url = each.find('a')['href']
    hem_img_url = hem_url+url
    
    browser.visit(hem_img_url)
    html = browser.html
    soup = BeautifulSoup(html, 'html.parser')
    hemisphere_img_original = soup.find('div',class_='downloads')
    hemisphere_img_url=hemisphere_img_original.find('a')['href']
    
    print(hemisphere_img_url)
    img_data = dict({'title':title, 'img_url': hemisphere_img_url})
    hemisphere_img_urls.append(img_data)
hemisphere_images_urls<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12535845964768538, 'fraction_numerical': 0.0061450225317492835, 'mean_word_length': 6.980392156862745, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '470031', 'license': 'ADSL', 'n_tokens_mistral': 948, 'n_tokens_neox': 929, 'n_words': 128, 'path': 'Missions_to_Mars/Mission_to_Mars.ipynb', 'repo_name': 'Lucasmvs1994/web-scraping-challenge', 'size': '2441'}