how to filter news article by its source, language through Python?

Options

Answers

  • Hello @christopher.olero

    You can see the LD Library, news examples on how to use the library to get news headlines and stories. The first parameter in the get_headlines is a query string which can take multiple arguments including source and language etc.

    Here is a sample query that I tried -

    ld.news.get_headlines(query='Topic:FUND AND Language:LEN NOT ( Source:DJN OR Source:NBSX OR Source:HIIS OR Source:HOSE OR Source:PHSE OR Source:BSE OR Source:FT OR Source:NZXR OR Source:LSE OR Source:SET OR Source:ASX OR Source:CMNW OR Source:JSE OR Source:IDX OR Source:SGX ) NOT ( ( "" AND "TOP NEWS" ) OR ( "" AND "Net Asset" ) OR ( "" AND "BRIEF-" ) OR ( "" AND "NAV" )', count=100)
    
    image.png

    The response is a Pandas dataframe, so the Python code can do more filtering after getting the resultset.

    If you need assistance with forming the search query, please reach out to LSEG Support.