Remove deprecated functions
Removed global default scraper
This commit is contained in:
parent
3eb86161ce
commit
66780eb801
5 changed files with 0 additions and 56 deletions
|
|
@ -75,11 +75,6 @@ func (s *Scraper) GetProfile(username string) (Profile, error) {
|
||||||
return parseProfile(jsn.Data.User.Legacy), nil
|
return parseProfile(jsn.Data.User.Legacy), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: GetProfile wrapper for default scraper
|
|
||||||
func GetProfile(username string) (Profile, error) {
|
|
||||||
return defaultScraper.GetProfile(username)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserIDByScreenName from API
|
// GetUserIDByScreenName from API
|
||||||
func (s *Scraper) GetUserIDByScreenName(screenName string) (string, error) {
|
func (s *Scraper) GetUserIDByScreenName(screenName string) (string, error) {
|
||||||
id, ok := cacheIDs.Load(screenName)
|
id, ok := cacheIDs.Load(screenName)
|
||||||
|
|
|
||||||
26
scraper.go
26
scraper.go
|
|
@ -46,8 +46,6 @@ const (
|
||||||
// default http client timeout
|
// default http client timeout
|
||||||
const DefaultClientTimeout = 10 * time.Second
|
const DefaultClientTimeout = 10 * time.Second
|
||||||
|
|
||||||
var defaultScraper *Scraper
|
|
||||||
|
|
||||||
// New creates a Scraper object
|
// New creates a Scraper object
|
||||||
func New() *Scraper {
|
func New() *Scraper {
|
||||||
jar, _ := cookiejar.New(nil)
|
jar, _ := cookiejar.New(nil)
|
||||||
|
|
@ -76,33 +74,18 @@ func (s *Scraper) SetSearchMode(mode SearchMode) *Scraper {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: SetSearchMode wrapper for default Scraper
|
|
||||||
func SetSearchMode(mode SearchMode) *Scraper {
|
|
||||||
return defaultScraper.SetSearchMode(mode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithDelay add delay between API requests (in seconds)
|
// WithDelay add delay between API requests (in seconds)
|
||||||
func (s *Scraper) WithDelay(seconds int64) *Scraper {
|
func (s *Scraper) WithDelay(seconds int64) *Scraper {
|
||||||
s.delay = seconds
|
s.delay = seconds
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: WithDelay wrapper for default Scraper
|
|
||||||
func WithDelay(seconds int64) *Scraper {
|
|
||||||
return defaultScraper.WithDelay(seconds)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithReplies enable/disable load timeline with tweet replies
|
// WithReplies enable/disable load timeline with tweet replies
|
||||||
func (s *Scraper) WithReplies(b bool) *Scraper {
|
func (s *Scraper) WithReplies(b bool) *Scraper {
|
||||||
s.includeReplies = b
|
s.includeReplies = b
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: WithReplies wrapper for default Scraper
|
|
||||||
func WithReplies(b bool) *Scraper {
|
|
||||||
return defaultScraper.WithReplies(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// client timeout
|
// client timeout
|
||||||
func (s *Scraper) WithClientTimeout(timeout time.Duration) *Scraper {
|
func (s *Scraper) WithClientTimeout(timeout time.Duration) *Scraper {
|
||||||
s.client.Timeout = timeout
|
s.client.Timeout = timeout
|
||||||
|
|
@ -149,12 +132,3 @@ func (s *Scraper) SetProxy(proxyAddr string) error {
|
||||||
}
|
}
|
||||||
return errors.New("only support http(s) or socks5 protocol")
|
return errors.New("only support http(s) or socks5 protocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: SetProxy wrapper for default Scraper
|
|
||||||
func SetProxy(proxy string) error {
|
|
||||||
return defaultScraper.SetProxy(proxy)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
defaultScraper = New()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
10
search.go
10
search.go
|
|
@ -11,21 +11,11 @@ func (s *Scraper) SearchTweets(ctx context.Context, query string, maxTweetsNbr i
|
||||||
return getTweetTimeline(ctx, query, maxTweetsNbr, s.FetchSearchTweets)
|
return getTweetTimeline(ctx, query, maxTweetsNbr, s.FetchSearchTweets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: SearchTweets wrapper for default Scraper
|
|
||||||
func SearchTweets(ctx context.Context, query string, maxTweetsNbr int) <-chan *TweetResult {
|
|
||||||
return defaultScraper.SearchTweets(ctx, query, maxTweetsNbr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SearchProfiles returns channel with profiles for a given search query
|
// SearchProfiles returns channel with profiles for a given search query
|
||||||
func (s *Scraper) SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult {
|
func (s *Scraper) SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult {
|
||||||
return getUserTimeline(ctx, query, maxProfilesNbr, s.FetchSearchProfiles)
|
return getUserTimeline(ctx, query, maxProfilesNbr, s.FetchSearchProfiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: SearchProfiles wrapper for default Scraper
|
|
||||||
func SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult {
|
|
||||||
return defaultScraper.SearchProfiles(ctx, query, maxProfilesNbr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// getSearchTimeline gets results for a given search query, via the Twitter frontend API
|
// getSearchTimeline gets results for a given search query, via the Twitter frontend API
|
||||||
func (s *Scraper) getSearchTimeline(query string, maxNbr int, cursor string) (*timeline, error) {
|
func (s *Scraper) getSearchTimeline(query string, maxNbr int, cursor string) (*timeline, error) {
|
||||||
if !s.isLogged {
|
if !s.isLogged {
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,3 @@ func (s *Scraper) GetTrends() ([]string, error) {
|
||||||
|
|
||||||
return trends, nil
|
return trends, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: GetTrends wrapper for default Scraper
|
|
||||||
func GetTrends() ([]string, error) {
|
|
||||||
return defaultScraper.GetTrends()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
10
tweets.go
10
tweets.go
|
|
@ -11,11 +11,6 @@ func (s *Scraper) GetTweets(ctx context.Context, user string, maxTweetsNbr int)
|
||||||
return getTweetTimeline(ctx, user, maxTweetsNbr, s.FetchTweets)
|
return getTweetTimeline(ctx, user, maxTweetsNbr, s.FetchTweets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: GetTweets wrapper for default Scraper
|
|
||||||
func GetTweets(ctx context.Context, user string, maxTweetsNbr int) <-chan *TweetResult {
|
|
||||||
return defaultScraper.GetTweets(ctx, user, maxTweetsNbr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FetchTweets gets tweets for a given user, via the Twitter frontend API.
|
// FetchTweets gets tweets for a given user, via the Twitter frontend API.
|
||||||
func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
|
func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
|
||||||
userID, err := s.GetUserIDByScreenName(user)
|
userID, err := s.GetUserIDByScreenName(user)
|
||||||
|
|
@ -76,8 +71,3 @@ func (s *Scraper) GetTweet(id string) (*Tweet, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("tweet with ID %s not found", id)
|
return nil, fmt.Errorf("tweet with ID %s not found", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: GetTweet wrapper for default Scraper
|
|
||||||
func GetTweet(id string) (*Tweet, error) {
|
|
||||||
return defaultScraper.GetTweet(id)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue