<jupyter_start><jupyter_text>SCRAPING<jupyter_code># Setup splinter
# -------------------------------------------------
executable_path = {'executable_path': ChromeDriverManager().install()}
browser = Browser('chrome', **executable_path, headless=False)
# URL of page to be scraped

url = ('https://redplanetscience.com/')
browser.visit(url)

soup = bs(browser.html, 'html.parser')
#Collect News titles from url
news_title = soup.find('div', class_="content_title").get_text()
news_title
# Collect News title paragraphs from url
news_p = soup.find('div', class_="article_teaser_body").get_text()
news_p<jupyter_output><empty_output><jupyter_text>IMAGES<jupyter_code># URL of page to be scraped
url2 = 'https://spaceimages-mars.com/'
browser.visit(url2)

soup = bs(browser.html, 'html.parser')
relative_image_path = soup.find_all('a')[2]["href"]

featured_image_url = url2 + relative_image_path

featured_image_url
#FEATURED IMAGE
relative_image_path<jupyter_output><empty_output><jupyter_text>FACTS<jupyter_code>#URL
url = 'https://galaxyfacts-mars.com/'
tables = pd.read_html(url)
tables
df = tables[0]
#df.head()
df.columns = ["Info","Mars","Earth"]
df
#REMOVE FIRST ROW
df = df.iloc[1:]
df
#TABLE TO HTML
html_table = df.to_html()
html_table<jupyter_output><empty_output><jupyter_text><NAME><jupyter_code># URL of page to be scraped
url3 = 'https://marshemispheres.com/'
browser.visit(url3)

soup = bs(browser.html, 'html.parser')
#GET A LIST OF ALL TITLES
title_list = []

titles = soup.find_all('h3')
titles
for title in titles:
    title_list.append(title.text)

title_list
# GET A LIST OF ALL URL'S
url_list = []

for title in title_list:
    url3 = 'https://marshemispheres.com/'
    browser.visit(url3)
    browser.click_link_by_partial_text(title)
    html = browser.html
    soup = bs(browser.html, 'html.parser')
    image_url = soup.find_all('li')[0].a["href"]
    dictionary = {"title": title,"image_url":url3+ image_url}
    url_list.append(dictionary)
url_list<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16450648055832504, 'fraction_numerical': 0.006480558325024925, 'mean_word_length': 5.232919254658385, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 18, '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': '254437', 'license': 'ADSL', 'n_tokens_mistral': 751, 'n_tokens_neox': 739, 'n_words': 141, 'path': 'Mission_to_Mars/mission_to_mars.ipynb', 'repo_name': 'KenyanBoy/Web-Scraping-Challenge', 'size': '2015'}