Skip to content

Commit

Permalink
updated get twitter trends
Browse files Browse the repository at this point in the history
  • Loading branch information
jdutchak committed Aug 1, 2024
1 parent 1d4280d commit 789a39b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/scrapers/twitter/tweets.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ func ScrapeTweetsByQuery(query string, count int) ([]*TweetResult, error) {
// ScrapeTweetsByTrends scrapes the current trending topics on Twitter.
// It returns a slice of strings representing the trending topics.
// If an error occurs during the scraping process, it returns an error.
func ScrapeTweetsByTrends() ([]string, error) {
func ScrapeTweetsByTrends() ([]*TweetResult, error) {
scraper := auth()
var tweets []string
var trendResults []*TweetResult

if scraper == nil {
return nil, fmt.Errorf("there was an error authenticating with your Twitter credentials")
Expand All @@ -154,13 +154,18 @@ func ScrapeTweetsByTrends() ([]string, error) {

trends, err := scraper.GetTrends()
if err != nil {
logrus.Printf("Error fetching tweet: %v", err)
return nil, err
}

tweets = append(tweets, trends...)
for _, trend := range trends {
trendResult := &TweetResult{
Tweet: &twitterscraper.Tweet{Text: trend},
Error: nil,
}
trendResults = append(trendResults, trendResult)
}

return tweets, nil
return trendResults, nil
}

// ScrapeTweetsProfile scrapes the profile and tweets of a specific Twitter user.
Expand Down

0 comments on commit 789a39b

Please sign in to comment.