For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 2 4

How to search headlines with multiple keywords? Why is such an input wrong?

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonnews
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

This query is a duplicate of the one in this comment.

1 Answer

Upvote
Accepted
39.2k 75 11 27

@yuyang
You typically don't need to use quotes around keywords. Try

ek.get_news_headlines("Product:IFRFM AND Topic:ISU AND Topic:EUB AND (PRICED OR DEAL)")
The above expression is syntactically correct, but returns an empty dataframe because the news search expression is too narrow and no headlines match it. Try instead for example:
ek.get_news_headlines("Topic:ISU AND Topic:EUB AND (PRICED OR DEAL)")
The reason your original news search expression results in an error is that Python library passes the news search expression string to a JSON object, which is then submitted in HTTP request to the Web service that delivers news headlines. This means that in order to escape a character you first need to escape it for Python and then for JSON. One way to do this is to use triple backslash:
"Topic:ISU AND Topic:EUB AND (\\\"PRICED\\\" OR \\\"DEAL\\\")"
Another is to use Python raw string:
r"Topic:ISU AND Topic:EUB AND (\"PRICED\" OR \"DEAL\")"

But as I said at the beginning the easiest is to not include keywords in quotes at all.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea