get_news_headline and quotation marks
hi there!
im trying to use the get_news_headlines function to pull out headlines for a list of entities.
The list if entities are saved on to a txt. file saved locally on my computer.
As an example, my txt file contains the name "SINGAPORE AEROSPACE MANUFACTURING PTE LTD". While running the get_news_headlines function, I pulled results for DAZN Pte Ltd. this occurs for other names as well. Please see search term on the right, along w the corresponding hits on the left.
Upon further investigation, my guess is that the search was not an exact search and hence threw out these items which I am not trying to get. Here is a screenshot of my search when manually performing the search via the News Monitor function on the app instead:
My guess is that my code searches for the term and they are often automatically replaced by other keywords in eikon (i.e., if I do not include " " into my search then it is replaced by Singapore AND Aerospace AND MFLZ etc.).
I tried changing my code to update the search terms with " " to make it an exact match but it seems to generate a 503 error whenever the " " is added. My guess is that these quotation marks do not work well with the get_news_headlines function.
any work around this? some snippets of my code as well:
import eikon as ek
import pandas as pd
from datetime import datetime, timedel
# Function to read search terms from a text file
def read_search_terms(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
return [line.strip() for line in file if line.strip()]
# Function to get news headlines using Eikon Data API
def get_news_headlines(query, date_from, date_to, count=5):
headlines = ek.get_news_headlines(query=query, count=count, date_from=date_from, date_to=date_to)
return headlines
any help is appreciated!
Best Answer
-
Thank you for reaching out to us.
You need to use the escape sequences for the double quotes.
ek.get_news_headlines(query="\\\"SINGAPORE AEROSPACE MANUFACTURING PTE LTD\\\"")
The output is:
You can also use the RD Library for Python.
headlines = rd.news.get_headlines('"SINGAPORE AEROSPACE MANUFACTURING PTE LTD"',count=100)
headlinesThe RD examples are on GitHub.
0
Answers
-
in contrast, this is my expected output
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛