I'm curious about how to increase the number in brackets using Python iterations.

Asked 2 years ago, Updated 2 years ago, 84 views

Hello. I'm asking you a question because I'm stuck while studying Twitter crawl on Python.

I thought the problem would be solved quickly because it was very simple, but I can't think of a solution.

//
import GetOldTweets3 as got
from bs4 import BeautifulSoup as bs
import datetime 
import time 



sweetCriteria = got.manager.TweetCriteria().setQuerySearch('Lunch Today')\
                                           .setSince("2020-01-01")\
                                           .setUntil("2020-05-13")\
                                           .setMaxTweets(100)

tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]


print(tweet.text)

It's a twitter crawl code.

tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0] In this part, I want to extract [0] from the range of 0 to 24, but I'm not sure how to use the repetition.

I've tried this before

//import GetOldTweets3 as got
from bs4 import BeautifulSoup as bs
import datetime 
import time 



sweetCriteria = got.manager.TweetCriteria().setQuerySearch('Gift Kakao Talk')\
                                           .setSince("2020-01-01")\
                                           .setUntil("2020-05-13")\
                                           .setMaxTweets(100)

for i in range(0,24):
    print(i)

tweet = got.manager.TweetManager.getTweets(tweetCriteria)[i]


print(tweet.text)

There are many other things besides this, but of course, it only comes from 0 to 24 and no text comes out.

How do we code to solve this?

python loops

2022-09-20 22:17

1 Answers

from bs4 import BeautifulSoup as bs
import datetime 
import time 



sweetCriteria = got.manager.TweetCriteria().setQuerySearch('Gift Kakao Talk')\
                                           .setSince("2020-01-01")\
                                           .setUntil("2020-05-13")\
                                           .setMaxTweets(100)

for i in range(0,24):
    tweet = got.manager.TweetManager.getTweets(tweetCriteria)[i]



print(tweet.text)


2022-09-20 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.