Hello everyone! I would like to understand how to obtain the headlines of all companies, for example, U.S. companies, on Python by inserting keywords, from 2020 to today. The code I used only works with 100 rows. Thank you!
Hi @Ida ,
Regarding the headlines, do you mean news headlines of companies?
Hi @raksina.samasiri,
yes!
I'd like to recommend you to use https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python instead of Eikon Data API because it's newer library and the new functions will be added to it only (Eikon Data APi is considered feature complete). Its quick start guide can be found at https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python/quick-start and here's the example code.
You can use News Monitor 2.0 application to help you form the query for the input of get news headlines function by simply use the news monitor app's search bar to form the query, then double click on the bar to get the query to be used.
Plus, there's a parameter 'count' that you can use to adjust number of new headlines returned, its default value is 100.
import lseg.data as ld ld.open_session() ld.news.get_headlines('R:LSEG.L AND Language:LEN', start='2024-02-20', end='2025-02-24', count=10000)
In case the number of news headlines returned is exceed this count limit, you can call the function again using the latest versionCreated return as 'start' parameter in another request (please also add wait time between each function call to prevent hitting a number of request per second limit)
You'll only be able to get news back to around end of 2023 only, as according to the Data Library limits and guidelines, the dept of history is limited to 15 months.
If you'd like to get more historical news, please contact your LSEG account representative about the proper product to be used.
Hi Raksina,
thank you for your help and sorry for the late reply. In case I would like to add keywords and other resctrinctions like firms ecc, how I can do?
Thank you!