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.
|
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.
|
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
|
### Get profile
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
|
|
|
||||||
21
scraper.go
21
scraper.go
|
|
@ -15,8 +15,7 @@ type Scraper struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
guestToken string
|
guestToken string
|
||||||
includeReplies bool
|
includeReplies bool
|
||||||
liveSearch bool
|
searchMode string
|
||||||
resultFilter string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultScraper *Scraper
|
var defaultScraper *Scraper
|
||||||
|
|
@ -29,22 +28,22 @@ func New() *Scraper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSearchLive enable/disable realtime search
|
// SetSearchLive enable/disable realtime search
|
||||||
func (s *Scraper) SetSearchLive(b bool) *Scraper {
|
func (s *Scraper) SetSearchLive(srctype bool) *Scraper {
|
||||||
s.liveSearch = b
|
if srctype {
|
||||||
|
s.searchMode = "live"
|
||||||
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSearchLive wrapper for default SetSearchLive
|
// SetSearchLive wrapper for default SetSearchLive
|
||||||
func SetSearchLive(b bool) *Scraper {
|
func SetSearchLive(srctype bool) *Scraper {
|
||||||
return defaultScraper.SetSearchLive(b)
|
return defaultScraper.SetSearchLive(srctype)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSearchPhotos filter search for photos only
|
// SetSearchPhotos filter search for photos only
|
||||||
func (s *Scraper) SetSearchPhotos(srctype bool) *Scraper {
|
func (s *Scraper) SetSearchPhotos(srctype bool) *Scraper {
|
||||||
if srctype {
|
if srctype {
|
||||||
s.resultFilter = "image"
|
s.searchMode = "image"
|
||||||
} else {
|
|
||||||
s.resultFilter = ""
|
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
@ -57,9 +56,7 @@ func SetSearchPhotos(srctype bool) *Scraper {
|
||||||
// SetSearchVideos filter search for videos only
|
// SetSearchVideos filter search for videos only
|
||||||
func (s *Scraper) SetSearchVideos(srctype bool) *Scraper {
|
func (s *Scraper) SetSearchVideos(srctype bool) *Scraper {
|
||||||
if srctype {
|
if srctype {
|
||||||
s.resultFilter = "video"
|
s.searchMode = "video"
|
||||||
} else {
|
|
||||||
s.resultFilter = ""
|
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,10 @@ func (s *Scraper) FetchSearchTweets(query string, maxTweetsNbr int, cursor strin
|
||||||
if cursor != "" {
|
if cursor != "" {
|
||||||
q.Add("cursor", cursor)
|
q.Add("cursor", cursor)
|
||||||
}
|
}
|
||||||
if s.liveSearch {
|
if s.searchMode == "live" {
|
||||||
q.Add("tweet_search_mode", "live")
|
q.Add("tweet_search_mode", s.searchMode)
|
||||||
}
|
} else {
|
||||||
if s.resultFilter != "" {
|
q.Add("result_filter", s.searchMode)
|
||||||
q.Add("result_filter", s.resultFilter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL.RawQuery = q.Encode()
|
req.URL.RawQuery = q.Encode()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue