Remove deprecated functions

Removed global default scraper
This commit is contained in:
Alexander Sheiko 2023-05-11 14:15:56 +03:00
parent 3eb86161ce
commit 66780eb801
5 changed files with 0 additions and 56 deletions

View file

@ -75,11 +75,6 @@ func (s *Scraper) GetProfile(username string) (Profile, error) {
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
func (s *Scraper) GetUserIDByScreenName(screenName string) (string, error) {
id, ok := cacheIDs.Load(screenName)

View file

@ -46,8 +46,6 @@ const (
// default http client timeout
const DefaultClientTimeout = 10 * time.Second
var defaultScraper *Scraper
// New creates a Scraper object
func New() *Scraper {
jar, _ := cookiejar.New(nil)
@ -76,33 +74,18 @@ func (s *Scraper) SetSearchMode(mode SearchMode) *Scraper {
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)
func (s *Scraper) WithDelay(seconds int64) *Scraper {
s.delay = seconds
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
func (s *Scraper) WithReplies(b bool) *Scraper {
s.includeReplies = b
return s
}
// Deprecated: WithReplies wrapper for default Scraper
func WithReplies(b bool) *Scraper {
return defaultScraper.WithReplies(b)
}
// client timeout
func (s *Scraper) WithClientTimeout(timeout time.Duration) *Scraper {
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")
}
// Deprecated: SetProxy wrapper for default Scraper
func SetProxy(proxy string) error {
return defaultScraper.SetProxy(proxy)
}
func init() {
defaultScraper = New()
}

View file

@ -11,21 +11,11 @@ func (s *Scraper) SearchTweets(ctx context.Context, query string, maxTweetsNbr i
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
func (s *Scraper) SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult {
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
func (s *Scraper) getSearchTimeline(query string, maxNbr int, cursor string) (*timeline, error) {
if !s.isLogged {

View file

@ -35,8 +35,3 @@ func (s *Scraper) GetTrends() ([]string, error) {
return trends, nil
}
// Deprecated: GetTrends wrapper for default Scraper
func GetTrends() ([]string, error) {
return defaultScraper.GetTrends()
}

View file

@ -11,11 +11,6 @@ func (s *Scraper) GetTweets(ctx context.Context, user string, maxTweetsNbr int)
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.
func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
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)
}
// Deprecated: GetTweet wrapper for default Scraper
func GetTweet(id string) (*Tweet, error) {
return defaultScraper.GetTweet(id)
}