HTML to TEXT style (News story)

Hi

I would like to get news in text in Jupyter Notebook.

But I can get news only in HTML.

How can I get text style news story?

headlines = ek.get_news_headlines('IBM')
for index, headline_row in headlines.iterrows():
story=ek.get_news_story(headline_row['storyId'])

print (story, content-Type: text/html)

Best Answer

  • With Jupyter Notebook, you can use HTML() to display it as HTML.

    from IPython.display import HTML
    ...

    headlines = ek.get_news_headlines('IBM')
    for index, headline_row in headlines.iterrows(): story=ek.get_news_story(headline_row['storyId'])

    HTML(story)

    image

Answers

  • A Python library is available for this : https://pypi.python.org/pypi/html2text

    There is more info here : https://github.com/Alir3z4/html2text/blob/master/docs/usage.md

    Simple example with options:

    import html2text
    ...
    text_maker = html2text.HTML2Text()
    text_maker.ignore_links = True
    text_maker.bypass_tables = False
    html_story = ek.get_news_story(headline_row['storyId'])
    text_story = = text_maker.handle(html_story)
    print(text_story)
  • I could get text based news. Thank you guys for your support.

  • It's difficult to identify the precise cause of the HTML formatting not functioning as intended in the absence of precise information regarding recent modifications or updates to the Refinitiv Data Library (RDP) API. Here are some recommendations to assist with troubleshooting the problem, though:


    API Documentation Updates:


    Check the official documentation for the RDP API to see if there have been any recent updates or changes related to the HTML formatting of news stories. Look for any new parameters or modifications to existing ones.

    Support or Release Notes:


    Reach out to Refinitiv's support or check their release notes for any announcements regarding changes to the API. They may provide information on updates, bug fixes, or changes in functionality that could impact how news stories are retrieved.

    Request Headers:


    Ensure that the request headers sent with your API request are correctly configured. Sometimes, changes in the API may require specific headers for the desired response format.

    API Version Compatibility:


    Make sure the RDP API version you are using and your code are compatible. Your code might need to be modified to function with the most recent version of the API if there have been revisions.

    Community or Forums:


    Check if there is a developer community or forums related to the Refinitiv Data Library. Other developers may have faced similar issues and could provide insights or solutions.

    Logging and Debugging:


    Enhance your logging and debugging mechanisms to capture more details about the API response. This can help identify whether the issue is on the API side or within your code.

    Contact Refinitiv Support:


    If all else fails, consider reaching out directly to Refinitiv's support for assistance. They should be able to provide specific guidance on the issue and any necessary updates to your implementation.