Revert "Fix SetSearchLive, SetSearchPhotos and SetSearchVideos"
This reverts commit b6887fca9c.
This commit is contained in:
parent
b6887fca9c
commit
1f25820556
3 changed files with 18 additions and 32 deletions
20
README.md
20
README.md
|
|
@ -65,23 +65,13 @@ func main() {
|
|||
|
||||
The search ends if we have 50 tweets.
|
||||
|
||||
### Search tweet in realtime
|
||||
```golang
|
||||
scraper.SearchLive(true)
|
||||
```
|
||||
|
||||
See [Rules and filtering](https://developer.twitter.com/en/docs/tweets/rules-and-filtering/overview/standard-operators) for build standard queries.
|
||||
|
||||
|
||||
#### Search tweet in realtime
|
||||
```golang
|
||||
scraper.SetSearchLive(true)
|
||||
```
|
||||
|
||||
#### Filter search
|
||||
```golang
|
||||
scraper.SetSearchPhotos(true)
|
||||
```
|
||||
or
|
||||
```golang
|
||||
scraper.SetSearchVideos(true)
|
||||
```
|
||||
|
||||
### Get profile
|
||||
|
||||
```golang
|
||||
|
|
|
|||
21
scraper.go
21
scraper.go
|
|
@ -15,8 +15,7 @@ type Scraper struct {
|
|||
client *http.Client
|
||||
guestToken string
|
||||
includeReplies bool
|
||||
liveSearch bool
|
||||
resultFilter string
|
||||
searchMode string
|
||||
}
|
||||
|
||||
var defaultScraper *Scraper
|
||||
|
|
@ -29,22 +28,22 @@ func New() *Scraper {
|
|||
}
|
||||
|
||||
// SetSearchLive enable/disable realtime search
|
||||
func (s *Scraper) SetSearchLive(b bool) *Scraper {
|
||||
s.liveSearch = b
|
||||
func (s *Scraper) SetSearchLive(srctype bool) *Scraper {
|
||||
if srctype {
|
||||
s.searchMode = "live"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// SetSearchLive wrapper for default SetSearchLive
|
||||
func SetSearchLive(b bool) *Scraper {
|
||||
return defaultScraper.SetSearchLive(b)
|
||||
func SetSearchLive(srctype bool) *Scraper {
|
||||
return defaultScraper.SetSearchLive(srctype)
|
||||
}
|
||||
|
||||
// SetSearchPhotos filter search for photos only
|
||||
func (s *Scraper) SetSearchPhotos(srctype bool) *Scraper {
|
||||
if srctype {
|
||||
s.resultFilter = "image"
|
||||
} else {
|
||||
s.resultFilter = ""
|
||||
s.searchMode = "image"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
@ -57,9 +56,7 @@ func SetSearchPhotos(srctype bool) *Scraper {
|
|||
// SetSearchVideos filter search for videos only
|
||||
func (s *Scraper) SetSearchVideos(srctype bool) *Scraper {
|
||||
if srctype {
|
||||
s.resultFilter = "video"
|
||||
} else {
|
||||
s.resultFilter = ""
|
||||
s.searchMode = "video"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ func (s *Scraper) FetchSearchTweets(query string, maxTweetsNbr int, cursor strin
|
|||
if cursor != "" {
|
||||
q.Add("cursor", cursor)
|
||||
}
|
||||
if s.liveSearch {
|
||||
q.Add("tweet_search_mode", "live")
|
||||
}
|
||||
if s.resultFilter != "" {
|
||||
q.Add("result_filter", s.resultFilter)
|
||||
if s.searchMode == "live" {
|
||||
q.Add("tweet_search_mode", s.searchMode)
|
||||
} else {
|
||||
q.Add("result_filter", s.searchMode)
|
||||
}
|
||||
|
||||
req.URL.RawQuery = q.Encode()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue