d60 / twikit

Twitter API Scraper | Without an API key | Twitter Internal API | Free | Twitter scraper | Twitter Bot
https://twikit.readthedocs.io/en/latest/twikit.html
MIT License
1.25k stars 143 forks source link

Capturing a Full Thread #127

Open kylesf opened 3 months ago

kylesf commented 3 months ago

Hi there! Thanks for all the work you have done. Can you let me know if I am miss understanding current functionally.

# tweet_id = 1771523442707235083 # Top of Thread
tweet_id = 1771523476014207446 # Middle of Thread

t = client.get_tweet_by_id(tweet_id)

thread = [*t.reply_to, t, *t.thread]

[f"Thread {i}: {tweet.text}" for i, tweet in enumerate(thread)]

Is it correct or incorrect to assume the output should be the same if its the top of the thread or the middle?

d60 commented 3 months ago

@kylesf yes, they should be the same

kylesf commented 3 months ago

@d60 They are not it appears upwards recursion is not working?

tweet_id = 1771523442707235083 # Top of Thread

['Thread 0: I’m the CEO of a $100 million business.\n\nBut the first 10 years of my career:\n\n• Rejected by Google (2x)\n• Fired by FB after 9 months\n• Built 10+ startups that didn’t work out\n\nHere are 18 pieces of brutally honest career advice (I wish I knew earlier): https://t.co/XLQ8Scu9gz',
 'Thread 1: 1/ It’s okay to feel lost\n\nWhen you’re in your 20s, you’re not supposed to know exactly what you want to do with your career.\n\nInstead of trying to predict your career path, focus on taking daily action. https://t.co/Zwgb2VOFoa',
 'Thread 2: 2/ Take more swings\n\nEarly on, you can afford to take more risks because you have fewer obligations.\n\n•\xa0Do free work to get your foot in the door\n•\xa0Fly across the country to meet with an investor\n• Start the crazy business idea with your roommate\n\nYou only need ONE to win.',
 'Thread 3: 3/ Be the hub\n\nWhen I graduated, I hosted meetups and conferences…even when I didn’t know anyone.\n\nThe people I helped like @ramit, @tferriss, and @RyanHoliday ended up helping me 15 years down the line.\n\nAsk the smartest people you know, “Who is ONE person I should meet?’ https://t.co/BJHUxBODKJ',
 'Thread 4: 4/ Document your learning online\n\nCreating content is a career cheat code.\n\nI’ve been writing on my personal blog since 2000 (!!)\n\nWorst case? You learn how to write and promote your work.\n\nBest case? You attract life-changing opportunities. https://t.co/cZAPOiA5La',
 'Thread 5: 5/ Learn copywriting\n\nCopywriting is not about hitting a word count or writing a five-paragraph essay.\n\nIt’s about capturing attention and persuading action.\n\nYou will never be disappointed by improving your communication skills.\n\nShoutout @nevmed for introducing it to me!',
 'Thread 6: 6/ Master the art of the cold email\n\nI’ve been sending cold emails since I was a freshman.\n\nThe best cold emails:\n\n•\xa0Get to the point\n•\xa0Instantly grab attention\n•\xa0Answer “What’s in it for me?”\n\nIf you shoot 100 shots, you’re bound to land one hit. https://t.co/Zal2orhtjE',
 'Thread 7: 7/ Mentors are overrated\n\nThe best way to find a mentor? Become someone worth mentoring.\n\n•\xa0Start things\n•\xa0Encounter a problem\n•\xa0Ask for SPECIFIC feedback, not advice\n•\xa0Report back on how you did\n•\xa0Repeat 🔁\n\nYou’ll realize you never needed a “mentor” in the first place.',
 'Thread 8: 8/ Build independent income streams\n\nGetting fired at Facebook taught me that EVERYONE is replaceable.\n\nStart more side hustles.\n\nYou’ll learn more, earn independent income, and maybe even replace your income to go full-time.',
 "Thread 9: 9/ Give way less f*cks about other people\n\nNo amount of money, followers, or acknowledgment will quench your thirst for fulfillment.\n\nThe people you’re trying to impress aren’t even thinking about you in the first place.\n\nDon't prove others wrong. Prove yourself right.",
 'Thread 10: 10/ Have more patience\n\nIn my 20s, I was impatient to get rich and famous. I beat myself up a ton.\n\nThat’s a miserable way to live. You don’t have to be so hard on yourself.\n\nIf you’re doing the reps, the results WILL pay off.\n\nBe impatient with actions and patient with results. https://t.co/PmVTvzTYKw',
 'Thread 11: 11/ Practice positive self-talk\n\nIt took years to make peace with the voice in my head.\n\nA practice that’s helped:\n\n"Any time you say something negative about yourself, also say something positive."\n\nYou can be your biggest critic as long as you’re also your biggest cheerleader.',
 'Thread 12: 12/ Don’t jump ship too early\n\nI regret shutting down CommunityNext (my conference business).\n\nSomeone else took that idea, ran with it, & sold it for multiple millions of dollars.\n\nInstead of quitting when it gets boring – find someone to run it while you work on the next thing.',
 'Thread 13: 13/ Don’t let work consume your life\n\nI worked A LOT in my 20s.\n\nI don’t regret it - but don’t forget to have fun too!\n\nPlay sports. Travel abroad. Hang out with friends.\n\nIronically, doing those things will give you more inspiration for your work.',
 'Thread 14: 14/ Peer up the career ladder\n\nI wish I job shadowed and interviewed more people.\n\nIt sounds cool to be a surgeon until you realize you have to deal with blood all day.\n\nDon’t let an impressive-sounding title distract you from what matters most: doing work you enjoy.',
 'Thread 15: 15/ Your network DOES matter\n\nAs cliche as it may be, the people in your life DO matter a ton.\n\nIf you can’t geographically, surround yourself digitally.\n\n•\xa0Who’s on your WhatsApp? Text groups? Twitter DMs?\n\nAnd are those people helping you get closer or further from your goals?',
 'Thread 16: 16/ Read more biographies\n\nA wise friend once told me, “There are million-dollar lessons hidden in $30 books.”\n\nBiographies give you a unique peek into the lives of great people.\n\nInstead of learning from your own mistakes, why not learn from those who have come before you?',
 "Thread 17: 17/ Keep a journal\n\nI’ve kept a private blog since my time at Facebook.\n\nIt’s helped me become aware of my thought process and emotions.\n\nYou don’t even need to share it online.\n\nDocument how you're thinking about your life as you’re living it.",
 'Thread 18: 18/ You’re gonna be okay\n\nIt’s okay if you don’t have everything figured out.\n\nZoom out. We’re just a bunch of monkeys floating around on a tiny rock in space.\n\nHang around optimistic people. Do things that inspire you. Enjoy the party while we’re around.\n\nIt will all work out.',
 'Thread 19: These are 18 pieces of brutally honest career advice for my younger self.\n\nIf you enjoyed this, follow @noahkagan for more content like this!\n\nYou can read the full article for free below: https://t.co/VHiUrEKjSD',
 'Thread 20: BONUS: Be intentional about partner selection\n\nBoth your business partner and life partner matter a ton.\n\nWho you’re with can either drag you down or lift you up.\n\nThe big three in life are WHERE you live, WHAT you do, and WHO you do it with.']

tweet_id = 1771523476014207446 # Middle of Thread

['Thread 0: 6/ Master the art of the cold email\n\nI’ve been sending cold emails since I was a freshman.\n\nThe best cold emails:\n\n•\xa0Get to the point\n•\xa0Instantly grab attention\n•\xa0Answer “What’s in it for me?”\n\nIf you shoot 100 shots, you’re bound to land one hit. https://t.co/Zal2orhtjE',
 'Thread 1: 7/ Mentors are overrated\n\nThe best way to find a mentor? Become someone worth mentoring.\n\n•\xa0Start things\n•\xa0Encounter a problem\n•\xa0Ask for SPECIFIC feedback, not advice\n•\xa0Report back on how you did\n•\xa0Repeat 🔁\n\nYou’ll realize you never needed a “mentor” in the first place.',
 'Thread 2: 8/ Build independent income streams\n\nGetting fired at Facebook taught me that EVERYONE is replaceable.\n\nStart more side hustles.\n\nYou’ll learn more, earn independent income, and maybe even replace your income to go full-time.',
 "Thread 3: 9/ Give way less f*cks about other people\n\nNo amount of money, followers, or acknowledgment will quench your thirst for fulfillment.\n\nThe people you’re trying to impress aren’t even thinking about you in the first place.\n\nDon't prove others wrong. Prove yourself right.",
 'Thread 4: 10/ Have more patience\n\nIn my 20s, I was impatient to get rich and famous. I beat myself up a ton.\n\nThat’s a miserable way to live. You don’t have to be so hard on yourself.\n\nIf you’re doing the reps, the results WILL pay off.\n\nBe impatient with actions and patient with results. https://t.co/PmVTvzTYKw',
 'Thread 5: 11/ Practice positive self-talk\n\nIt took years to make peace with the voice in my head.\n\nA practice that’s helped:\n\n"Any time you say something negative about yourself, also say something positive."\n\nYou can be your biggest critic as long as you’re also your biggest cheerleader.',
 'Thread 6: 12/ Don’t jump ship too early\n\nI regret shutting down CommunityNext (my conference business).\n\nSomeone else took that idea, ran with it, & sold it for multiple millions of dollars.\n\nInstead of quitting when it gets boring – find someone to run it while you work on the next thing.',
 'Thread 7: 13/ Don’t let work consume your life\n\nI worked A LOT in my 20s.\n\nI don’t regret it - but don’t forget to have fun too!\n\nPlay sports. Travel abroad. Hang out with friends.\n\nIronically, doing those things will give you more inspiration for your work.',
 'Thread 8: 14/ Peer up the career ladder\n\nI wish I job shadowed and interviewed more people.\n\nIt sounds cool to be a surgeon until you realize you have to deal with blood all day.\n\nDon’t let an impressive-sounding title distract you from what matters most: doing work you enjoy.',
 'Thread 9: 15/ Your network DOES matter\n\nAs cliche as it may be, the people in your life DO matter a ton.\n\nIf you can’t geographically, surround yourself digitally.\n\n•\xa0Who’s on your WhatsApp? Text groups? Twitter DMs?\n\nAnd are those people helping you get closer or further from your goals?',
 'Thread 10: 16/ Read more biographies\n\nA wise friend once told me, “There are million-dollar lessons hidden in $30 books.”\n\nBiographies give you a unique peek into the lives of great people.\n\nInstead of learning from your own mistakes, why not learn from those who have come before you?',
 "Thread 11: 17/ Keep a journal\n\nI’ve kept a private blog since my time at Facebook.\n\nIt’s helped me become aware of my thought process and emotions.\n\nYou don’t even need to share it online.\n\nDocument how you're thinking about your life as you’re living it.",
 'Thread 12: 18/ You’re gonna be okay\n\nIt’s okay if you don’t have everything figured out.\n\nZoom out. We’re just a bunch of monkeys floating around on a tiny rock in space.\n\nHang around optimistic people. Do things that inspire you. Enjoy the party while we’re around.\n\nIt will all work out.',
 'Thread 13: These are 18 pieces of brutally honest career advice for my younger self.\n\nIf you enjoyed this, follow @noahkagan for more content like this!\n\nYou can read the full article for free below: https://t.co/VHiUrEKjSD',
 'Thread 14: BONUS: Be intentional about partner selection\n\nBoth your business partner and life partner matter a ton.\n\nWho you’re with can either drag you down or lift you up.\n\nThe big three in life are WHERE you live, WHAT you do, and WHO you do it with.']
kylesf commented 3 months ago

@d60 If no ideas come to mind, happy to debug the library code and try to find where the issue may be coming from. Just wanted to double check before diving into the code base!

kuomsy commented 1 month ago

Hi, first of all thank you for your work !

I'm also trying to get a thread starting from a tweet but the keys: "thread" & "reply_to" are None. The only info I have is "in_reply_to", I manage to obtain the previous tweet id.

I know I can use get_tweet_by_id until I obtain the full thread but it would hit the rate limits and wouldn't scale.

I'm trying to build a bot such as MakeItAQuote, that would trigger an action based on the tweets above when mentioned but I can't find a solution using your library. Do you have any idea ?

Thanks again!