DEV Community

Mvuselelo Houston Khanyile
Mvuselelo Houston Khanyile

Posted on

How do I extract a nested tuple from a tuple?

I'm using snscrape to scrape instagram. snscrape returns the data in tuple format but it creates the instagram data in a nested tuple. eg.

for b in enumerate(sninstagram.InstagramUserScraper(username='houston_2731').get_items())
        print[(b)]

output

(0, InstagramPost(url='https://www.instagram.com/p/CUdFfjEImHN/', date=datetime.datetime(2021, 9, 30, 17, 39, 20, tzinfo=datetime.timezone.utc), content='"Hardwork plus patience. A symbol of my sacrifice I\'m doing waiting."

Top comments (1)

Collapse
 
jonesrussell profile image
Russell Jones

Does this work?

for b in enumerate(sninstagram.InstagramUserScraper(username='houston_2731').get_items()):
instagram_post = b[1]
print(f"URL: {instagram_post.url}, Date: {instagram_post.date}, Content: {instagram_post.content}")