Esempio n. 1
0
 def test_returned_string(self):
     for trend in get_trends():
         self.assertIsInstance(trend, str)
Esempio n. 2
0
 def test_returned(self):
     self.assertIsInstance(get_trends(), list)
Esempio n. 3
0
 def get_trends_tags(self) -> list:
     return get_trends()
Esempio n. 4
0
from twitter_scraper import get_trends, get_tweets

print(get_trends())

getTweets = get_tweets('#malamjumat', pages=1)
for tweets in getTweets:
    print(tweets['text'])
Esempio n. 5
0
from twitter_scraper import get_tweets, get_trends

get_trends()
Esempio n. 6
0
import twitter_scraper as t
import urllib.request

trends = t.get_trends()
pages_to_search = 10
ids = []


def dl_img(url, name):
    path = f'./images/{name}.jpg'
    urllib.request.urlretrieve(url, path)


for trend in trends:
    try:
        for i in range(1, pages_to_search):
            for tweet in t.get_tweets(trend, pages=i):
                if len(tweet['entries']['photos']):
                    t_id = tweet['tweetId']
                    if t_id not in ids:
                        ids.append(t_id)
                        for j in range(0, len(tweet['entries']['photos'])):
                            try:
                                url = tweet['entries']['photos'][j]
                                name = f'{trend}_{t_id}_{j}'
                                dl_img(url, name)
                                print('image downloaded')
                            except:
                                print('couldn\'t download image')
                    else:
                        print('image already downloaded')