I am trying to get the image links from Twitter posts. When I tried to do this with the Twitter API, I only get the link of images if they are posted as images but most newspapers post a link to their whole report including an image. I am trying to get the image inside that link. This is normally the basic way to get the link example. However, in my case, an image can be hidden under a link like this example from twitter. I have tried solutions like beautifulsoup but the HTML response I get doesn't make any sense. It doesn't include any of the attributes or classes I am searching for. This is the code I tried:
url = "https://twitter.com/derspiegel/status/1511961740694614016"
res = requests.get(url)
soup = BeautifulSoup(res.content, "html.parser")
print(soup)
comicElem = soup.find_all(class_="css-9pa8cd")
print(comicElem)
Does anyone have an idea to get this done with Twitter API or any other method?