<jupyter_start><jupyter_text>NASA Mars News<jupyter_code># URL of page to be scraped
url = 'https://mars.nasa.gov/news'
#Using splinter to visit the url and convert to html
browser.visit(url)
html = browser.html

# Create BeautifulSoup object; parse with 'html.parser'
soup = bs(html, 'html.parser')
print(type(soup))


time.sleep(5)
# latest News Title and Paragraph Text
slide_elem = soup.select_one('ul.item_list li.slide')

news_title = slide_elem.find('div', class_="content_title").find('a').text
news_date = slide_elem.find('div', class_="list_date").text
print(news_title)
print(news_date)

#Alternatively the news_title and news_p can be extracted as below:
# time.sleep(5)
# news_title = soup.find('div', class_="content_title").find('a').text
# news_date = soup.find('div', class_="list_date").text
# print(news_title)
# print(news_date)
news_p = slide_elem.find('div', class_="article_teaser_body").text
print(news_p)<jupyter_output>The bit carousel, which lies at the heart of the rover's Sample Caching System, is now aboard NASA's newest rover.<jupyter_text>JPL Mars Space Images - Featured Image<jupyter_code>url = 'https://www.jpl.nasa.gov/spaceimages/?search=&category=Mars'
browser.visit(url)
html = browser.html
soup = bs(html, 'html.parser')
print(type(soup))
extracted_img_url = soup.find('article')['style']
print(f'Link:{extracted_img_url}')

full_image_url = soup.find('a', class_="button fancybox")['data-fancybox-href']
print(f'Full Image Link:{full_image_url}')
#splitting the url to get only the basename
url = url.split('?')[0]
print(url)

# Create a list of each bit between slashes
slashparts = url.split('/')
# Now join back the first three sections 'http:', '' and 'www.jpl.nasa.gov'
basename = '/'.join(slashparts[:3])

print(basename)
featured_img_url = basename + full_image_url
print(featured_img_url)<jupyter_output>https://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA18058_ip.jpg<jupyter_text>Mars Weather<jupyter_code>url_twitter = 'https://twitter.com/marswxreport?lang=en'
browser.visit(url_twitter)
html_twitter = browser.html
soup = bs(html_twitter, 'html.parser')
print(type(soup))
mars_weather = soup.find('p', class_="TweetTextSize TweetTextSize--normal js-tweet-text tweet-text").text

print(mars_weather)<jupyter_output>"Dusty" the Earthbound twin (triplet?) of @MarsRovers  Opportunity & Spirit is heading for a new home at the National @airandspace Museum.https://twitter.com/AstroStaab/status/1162103864608169984 …<jupyter_text>Mars Facts<jupyter_code>url = 'https://space-facts.com/mars/'
tables = pd.read_html(url)

mars_facts_df = tables[1]
mars_facts_df.columns = ['Mars Planet Profile', 'Fact Values']
mars_facts_df.set_index(["Mars Planet Profile"])
mars_facts_html = mars_facts_df.to_html()
mars_facts_htmlstring = mars_facts_html.replace("\n", "")
mars_facts_htmlstring<jupyter_output><empty_output><jupyter_text>Mars Hemispheres<jupyter_code>url_hemisphere = 'https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars'
browser.visit(url_hemisphere)
html_hemisphere = browser.html
soup = bs(html_hemisphere, 'html.parser')
print(type(soup))
#Complete url to split into base value
url = 'https://astrogeology.usgs.gov/search/results?q=hemisphere+enhanced&k1=target&v1=Mars'
#splitting the url to get only the basename
url = url.split('?')[0]
# Create a list of each bit between slashes
slashparts = url.split('/')
# Now join back the first three sections 'http:', '' and 'astrogeology.usgs.gov'
basename = '/'.join(slashparts[:3])

print(basename)

#Find all titles 
titles = soup.find_all('div', class_='description')


hemisphere_image_urls = []

for result in titles:
    
    each_title = result.find('h3').text
    each_image_links = result.a['href']
    full_img_links = basename + each_image_links
    
    browser.visit(full_img_links)
    new_html = browser.html
    soup = bs(new_html, 'html.parser')
    partial_img_url = soup.find("img", class_="wide-image")["src"]
    complete_img_url = basename + partial_img_url
    hemisphere_image_urls.append({"title": each_title, "img_url": complete_img_url})
           
print(hemisphere_image_urls)<jupyter_output>[{'title': 'Cerberus Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/cfa62af2557222a02478f1fcd781d445_cerberus_enhanced.tif_full.jpg'}, {'title': 'Schiaparelli Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/3cdd1cbf5e0813bba925c9030d13b62e_schiaparelli_enhanced.tif_full.jpg'}, {'title': 'Syrtis Major Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/ae209b4e408bb6c3e67b6af38168cf28_syrtis_major_enhanced.tif_full.jpg'}, {'title': 'Valles Marineris Hemisphere Enhanced', 'img_url': 'https://astrogeology.usgs.gov/cache/images/7cf2da4bf549ed01c17f206327be4db7_valles_marineris_enhanced.tif_full.jpg'}]
{'fraction_non_alphanumeric': 0.1379381443298969, 'fraction_numerical': 0.02309278350515464, 'mean_word_length': 6.79903536977492, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 12, 'lorem ipsum': 0, 'www.': 3, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '431714', 'license': 'ADSL', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1770, 'n_words': 322, 'path': 'mission_to_mars.ipynb', 'repo_name': 'prathamantri/Mission-to-Mars', 'size': '4850'}