<jupyter_start><jupyter_text>NASA Mars News<jupyter_code># Windows
executable_path = {"executable_path": "driver/chromedriver.exe"}
browser = Browser("chrome", **executable_path)
# Browser visit
url = "https://mars.nasa.gov/news/"
browser.visit(url)
html = browser.html
soup = bs(html, "html.parser")
# Get the latest news title
latest_news=soup.find("div",class_="list_text")
news_title=latest_news.find("div",class_="content_title").get_text()
news_title
# Get the paragraph of the latest news
news_p=latest_news.find("div",class_="article_teaser_body").get_text()
news_p<jupyter_output><empty_output><jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code># Visit browser
executable_path = {"executable_path": "driver/chromedriver.exe"}
browser = Browser("chrome", **executable_path)
url = "https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars"
browser.visit(url)
# Get the href of the featured image
html=browser.html
soup=bs(html,"html.parser")
full_image_button=soup.find("a",class_="button fancybox")
link=full_image_button["data-fancybox-href"]
featured_image_url="https://www.jpl.nasa.gov"+link
featured_image_url<jupyter_output><empty_output><jupyter_text>Mars Weather<jupyter_code># Visit browser
executable_path = {"executable_path": "driver/chromedriver.exe"}
browser = Browser("chrome", **executable_path)
url = "https://twitter.com/marswxreport?lang=en"
browser.visit(url)
# Get the Mars weather information
html=browser.html
soup=bs(html,"html.parser")
mars_weather=(soup.find_all("div",lang="en")[0].text).split("InSight ",1)[1]
mars_weather<jupyter_output><empty_output><jupyter_text>Mars Facts<jupyter_code># Get the table from html
url="https://space-facts.com/mars/"
table=pd.read_html(url)[0]
table
# Organize the dataframe
mars_df=table
mars_df.columns=["Info","Facts"]
mars_df.set_index("Info",inplace=True)
mars_df<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code># Visit the link
executable_path = {"executable_path": "driver/chromedriver.exe"}
browser = Browser("chrome", **executable_path)
url = "https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars"
browser.visit(url)
# Create lists: links - save for all hemspheres, hemisphere_image_urls - save all information required
links=[]
hemisphere_image_urls=[]

# Get the list of links
html=browser.html
soup=bs(html,"html.parser")
items=soup.find_all("div",class_="item")
for item in items:
    links.append('https://astrogeology.usgs.gov'+item.find('a')['href'])
links
# Use a for-loop to fill the information we need in the list
for link in links:
    hemisphere={}
    browser.visit(link)
    html=browser.html
    soup=bs(html,"html.parser")
    hemisphere["title"]=soup.find('div',class_='content').find('h2').text
    hemisphere["img_url"]=soup.find('div',class_='downloads').find('a')['href']
    hemisphere_image_urls.append(hemisphere)
hemisphere_image_urls<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15353260869565216, 'fraction_numerical': 0.002377717391304348, 'mean_word_length': 8.290220820189274, 'pattern_counts': {'":': 4, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 7, 'lorem ipsum': 0, 'www.': 2, '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': '339091', 'license': 'ADSL', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1060, 'n_words': 170, 'path': 'Mission to Mars/mission_to_mars.ipynb', 'repo_name': 'xshi64/web-scraping-challenge', 'size': '2944'}