<jupyter_start><jupyter_text>Collect the latest News Title and Paragraph Text<jupyter_code>executable_path = {'executable_path': 'chromedriver.exe'}
browser = Browser('chrome', **executable_path, headless=False)
# URL of page to be scraped
url = "https://mars.nasa.gov/news/"
browser.visit(url)
# Create BeautifulSoup object; parse with 'html.parser'
html = browser.html
soup = BeautifulSoup(html, 'html.parser')
#  getting latest news title and paragraph from nasa news url
news_title = soup.find("div",class_="content_title").text
print(f"News Title: {news_title}")
news_p = soup.find("div", class_="article_teaser_body").text
print(f"News Paragraph: {news_p}")<jupyter_output>News Title: NASA's Mars 2020 Will Hunt for Microscopic Fossils
News Paragraph: A new paper identifies a ring of minerals at the rover's landing site that are ideal for fossilizing microbial life.<jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>space_image_url = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(space_image_url)
space_image_html = browser.html
soup = BeautifulSoup(space_image_html,"html.parser")
image = soup.find('img', class_ = 'thumb')['src']
featured_image_url = "https://www.jpl.nasa.gov" + image
print(f"Space Image URL : {featured_image_url}")<jupyter_output>Space Image URL : https://www.jpl.nasa.gov/spaceimages/images/wallpaper/PIA23539-640x350.jpg<jupyter_text>Mars Weather<jupyter_code># scrape the latest Mars weather tweet
mars_weather_url = "https://twitter.com/marswxreport?lang=en"
browser.visit(mars_weather_url)
# Create BeautifulSoup object; parse with 'html.parser'
weather_html = browser.html
soup = BeautifulSoup(weather_html, 'html.parser')
#  Save the tweet text for the weather report as a variable called
mars_weather = soup.find("p", class_="TweetTextSize TweetTextSize--normal js-tweet-text tweet-text").text
print(f"Mars Weather Tweet : {mars_weather}")<jupyter_output>Mars Weather Tweet : InSight sol 342 (2019-11-13) low -99.9ºC (-147.8ºF) high -23.3ºC (-9.9ºF)
winds from the SW at 5.2 m/s (11.7 mph) gusting to 20.5 m/s (46.0 mph)
pressure at 6.90 hPapic.twitter.com/NO4iCrXgrl<jupyter_text>Mars Facts<jupyter_code>mars_fact_url = "https://space-facts.com/mars/"
# browser.visit(mars_fact_url)
mars_table = pd.read_html(mars_fact_url)
# print(mars_table)
df = mars_table[0]
df.columns = ['description', 'values']
df = df.set_index('description')
df.head(15)
mars_facts = df.to_html()
print(mars_facts)
#  saving the html file as table.hyml
df.to_html('table.html')<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>hemispheres_url = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
browser.visit(hemispheres_url)
hemisphere_html = browser.html
soup = BeautifulSoup(hemisphere_html, 'html.parser')

hemisphere_list = []

category = soup.find("div", class_ = "result-list" )
hemispheres =category.find_all("div", class_="item")

for hemisphere in hemispheres:
    title = hemisphere.find("h3").text
    title = title.strip("Enhanced")
    end_link = hemisphere.find("a")["href"]
    image_link = "https://astrogeology.usgs.gov/" + end_link    
    browser.visit(image_link)
    hemisphere_html = browser.html
    soup = BeautifulSoup(hemisphere_html, 'html.parser')
    downloads = soup.find("div", class_="downloads")
    image_url = downloads.find("a")["href"]
    hemisphere_list.append({"title": title, "img_url": image_url})
hemisphere_list<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13312428734321552, 'fraction_numerical': 0.016818700114025087, 'mean_word_length': 6.325678496868476, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 8, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '489177', 'license': 'ADSL', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1251, 'n_words': 254, 'path': 'mission_to_mars.ipynb', 'repo_name': 'ankitapatel9/web-scraping-challenge', 'size': '3508'}