Merge pull request #6 from imperatrona/home

Add Home Latest & For you timelines
This commit is contained in:
Valentine 2024-07-09 06:11:33 +03:00 committed by GitHub
commit 11f7b6ef5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 401 additions and 0 deletions

View file

@ -24,6 +24,8 @@ You can use this library to get tweets, profiles, and trends trivially.
- [Get user tweets](#get-user-tweets)
- [Get user medias](#get-user-medias)
- [Get bookmarks](#get-bookmarks)
- [Get home tweets](#get-home-tweets)
- [Get foryou tweets](#get-foryou-tweets)
- [Search tweets](#search-tweets)
- [Search params](#search-params)
- [Get profile](#get-profile)
@ -270,6 +272,56 @@ var cursor string
tweets, cursor, err := scraper.FetchBookmarks(20, cursor)
```
### Get home tweets
> [!IMPORTANT]
> Requires authentication!
500 requests / 15 minutes
`GetHomeTweets` returns a channel with the specified number of latest home tweets. Its using the `FetchHomeTweets` method under the hood.
```golang
for tweet := range scraper.GetHomeTweets(context.Background(), 50) {
if tweet.Error != nil {
panic(tweet.Error)
}
fmt.Println(tweet.Text)
}
```
`FetchHomeTweets` returns latest home tweets and cursor for fetching the next page. Each request returns up to 20 tweets.
```golang
var cursor string
tweets, cursor, err := scraper.FetchHomeTweets(20, cursor)
```
### Get foryou tweets
> [!IMPORTANT]
> Requires authentication!
500 requests / 15 minutes
`GetForYouTweets` returns a channel with the specified number of for you home tweets. Its using the `FetchForYouTweets` method under the hood.
```golang
for tweet := range scraper.GetForYouTweets(context.Background(), 50) {
if tweet.Error != nil {
panic(tweet.Error)
}
fmt.Println(tweet.Text)
}
```
`FetchForYouTweets` returns for you home tweets and cursor for fetching the next page. Each request returns up to 20 tweets.
```golang
var cursor string
tweets, cursor, err := scraper.FetchForYouTweets(20, cursor)
```
### Search tweets
> [!IMPORTANT]