How to get the image file with imageId?

Hi,

I ended up having the news 'imageId' but i don't know how to get the image by using 'imageId'


here is the code :


top_news = rd.content.news.top_news.hierarchy.Definition().get_data();

front_page = rd.content.news.top_news.Definition(top_news.data.df["topNewsId"][0]).get_data()

daf = front_page.data.df

for i in range(len(daf)):

print(daf.headline[i])

print(daf.storyId[i])

print(daf.imageId[i])


but when i get the contents by using 'storyId', The image file is not included in html..

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @jwlee08

    Please try the code below.

    from refinitiv.data.content import news

    top_news = news.top_news.hierarchy.Definition().get_data();
    #Front Page News
    front_page = news.top_news.Definition(top_news.data.df["topNewsId"][0]).get_data()
    front_page.data.df

    1702538587308.png

    Then, get an image.

    definition = news.images.Definition(front_page.data.df["imageId"][0])
    response = definition.get_data()
    image = response.data.image
    image.show()

Answers