<jupyter_start><jupyter_text>---- Data Library for Python----  Content layer - NewsThis notebook demonstrates how to retrieve News.  Learn moreTo learn more about the Refinitiv Data Library for Python please join the Refinitiv Developer Community. By [registering](https://developers.refinitiv.com/iam/register) and [logging](https://developers.refinitiv.com/content/devportal/en_us/initCookie.html) into the Refinitiv Developer Community portal you will have free access to a number of learning materials like  [Quick Start guides](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-library-for-python/quick-start),  [Tutorials](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-library-for-python/learning),  [Documentation](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-library-for-python/docs) and much more. Getting Help and SupportIf you have any questions regarding using the API, please post them on the [Refinitiv Data Q&A Forum](https://community.developers.refinitiv.com/spaces/321/index.html). The Refinitiv Developer Community will be happy to help.   Set the configuration file locationFor a better ease of use, you have the option to set initialization parameters of the Refinitiv Data Library in the _refinitiv-data.config.json_ configuration file. This file must be located beside your notebook, in your user folder or in a folder defined by the _RD_LIB_CONFIG_PATH_ environment variable. The _RD_LIB_CONFIG_PATH_ environment variable is the option used by this series of examples. The following code sets this environment variable.<jupyter_code>import os
os.environ["RD_LIB_CONFIG_PATH"] = "../../../Configuration"<jupyter_output><empty_output><jupyter_text>Some Imports to start with<jupyter_code>import refinitiv.data as rd
from refinitiv.data.content import news
from datetime import timedelta<jupyter_output><empty_output><jupyter_text>Open the data sessionThe open_session() function creates and open sessions based on the information contained in the refinitiv-data.config.json configuration file. Please edit this file to set the session type and other parameters required for the session you want to open.<jupyter_code>rd.open_session('platform.rdp')<jupyter_output><empty_output><jupyter_text>Retrieve data  Headlines  Get headlines<jupyter_code>response = news.headlines.Definition("Apple").get_data()
response.data.df<jupyter_output><empty_output><jupyter_text>Get headlines within a range of dates<jupyter_code>response = news.headlines.Definition(
    query="Refinitiv",
    date_from="20.03.2021", 
    date_to=timedelta(days=-4), 
    count=3
).get_data()
response.data.df<jupyter_output><empty_output><jupyter_text>Get a limited number of headlines<jupyter_code>response = news.headlines.Definition(query = "Google", count = 350).get_data()
response.data.df<jupyter_output><empty_output><jupyter_text>Story<jupyter_code>response = news.story.Definition("urn:newsml:reuters.com:20211003:nNRAgvhyiu:1").get_data()
print(response.data.story.title, '\n')
print(response.data.story.content)<jupyter_output>Google Doodle marks birthday of Spanish ocean scientist <NAME> los <NAME> 

For best results when printing this announcement, please click on link below:
http://newsfile.refinitiv.com/getnewsfile/v1/story?guid=urn:newsml:reuters.com:20211003:nNRAgvhyiu&default-theme=true


The Google Doodle today (3 OCtober) celebrates the 105th birthday of
Spanish-American professor and marine research biologist <NAME>
Ángeles <NAME>, who is regarded as one of the most important
Spanish scientists of all time.

Born in 1916, her love of natural history began with her father's library and
deepened as she pursued coastline oceanography research.

Although the Spanish Institute of Oceanography (IEO) only accepted men at the
time, her university work impressed the organization so much that they
appointed her as a marine biologist in 1952.

Based in Vigo, she began her pioneering research on zooplankton, tiny
organisms that serve as the foundation of the oceanic food c[...]<jupyter_text>Close the session<jupyter_code>rd.close_session()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08576859111427892, 'fraction_numerical': 0.01092896174863388, 'mean_word_length': 6.184300341296928, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '1711', 'license': 'Apache-2.0', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1205, 'n_words': 384, 'path': 'Examples/2-Content/2.03-News/EX-2.03.01-News.ipynb', 'repo_name': 'Refinitiv-API-Samples/Example.DataLibrary.Python', 'size': '4247'}