<jupyter_start><jupyter_text>NASA Mars News<jupyter_code># URL of page to be scraped
url = 'https://redplanetscience.com/'
browser.visit(url)

# Retrieve page with the requests module
html = browser.html
# Create BeautifulSoup object; parse with 'lxml'
soup = BeautifulSoup(html, 'html.parser')
soup
results = soup.find_all('section', class_='image_and_description_container')
results
results = soup.find_all('div', class_='list_text')
results
for result in results:
    news_title = result.find('div', class_='content_title').text
    news_p = result.find('div', class_='article_teaser_body').text
    
    print("--------------------")
    print(f'Title: {news_title}')
    print(f'News: {news_p}')
mars_data = {}
mars_data['title'] = news_title
mars_data['news']  = news_p
    
mars_data<jupyter_output><empty_output><jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code># URL of page to be scraped
url = 'https://spaceimages-mars.com/'
browser.visit(url)

# Retrieve page with the requests module
html = browser.html
# Create BeautifulSoup object; parse with 'lxml'
soup = BeautifulSoup(html, 'html.parser')
soup
results = soup.find('img', class_='headerimage fade-in')['src']
featured_image_url = urljoin(url, results)
featured_image_url
mars_data['featured_image_url'] = featured_image_url
mars_data<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code>url = 'https://galaxyfacts-mars.com/'
tables = pd.read_html(url)
tables
df = tables[0]
df.columns=['Mars-Earth Comparison', 'Mars', 'Earth']
df.drop(0, inplace=True)
df.head()
html_content = [df.columns.values.tolist()] + df.values.tolist()
html_content
mars_data["mars_facts"] = html_content
mars_data
mars_profile = tables[1]
mars_profile.columns = ['MARS PLANET PROFILE','']
mars_profile.head()<jupyter_output><empty_output><jupyter_text><NAME><jupyter_code>url = 'https://marshemispheres.com/'
browser.visit(url)
html = browser.html
soup = BeautifulSoup(html, 'html.parser')

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

items
url = 'https://marshemispheres.com/'
hemisphere_image_urls = []


for item in items:
    element = {}
    link = item.find('a', class_='itemLink')['href']
    title = item.find('h3').text
    print('-------------------------')
    print(link)
    print(title)

    browser.visit(url+link)
    html = browser.html
    soup = BeautifulSoup(html, 'html.parser')
    downloads = soup.find('div', class_='downloads')
    #img = downloads.find('img', class_='thumb')['src']
    img = downloads.ul.li.find('a')['href']
    print(urljoin(url,img))

    element["title"] = title
    element["img_url"] = urljoin(url,img)
    
    hemisphere_image_urls.append(element)

hemisphere_image_urls
mars_data["hemisphere_images_urls"] = hemisphere_image_urls
mars_data
browser.quit()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16216216216216217, 'fraction_numerical': 0.001422475106685633, 'mean_word_length': 5.237250554323725, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '654579', 'license': 'ADSL', 'n_tokens_mistral': 1013, 'n_tokens_neox': 1002, 'n_words': 182, 'path': 'Missions_to_Mars/mission_to_mars.ipynb', 'repo_name': 'leoipn/web-scraping-challenge', 'size': '2822'}