Add authentication
Breaking changes: removed WithCookie and WithXCsrfToken
This commit is contained in:
parent
3d364abaac
commit
eb18988829
7 changed files with 236 additions and 33 deletions
23
scraper.go
23
scraper.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -21,11 +22,9 @@ type Scraper struct {
|
|||
guestToken string
|
||||
guestCreatedAt time.Time
|
||||
includeReplies bool
|
||||
isLogged bool
|
||||
searchMode SearchMode
|
||||
wg sync.WaitGroup
|
||||
|
||||
cookie string
|
||||
xCsrfToken string
|
||||
}
|
||||
|
||||
// SearchMode type
|
||||
|
|
@ -51,9 +50,13 @@ var defaultScraper *Scraper
|
|||
|
||||
// New creates a Scraper object
|
||||
func New() *Scraper {
|
||||
jar, _ := cookiejar.New(nil)
|
||||
return &Scraper{
|
||||
bearerToken: bearerToken,
|
||||
client: &http.Client{Timeout: DefaultClientTimeout},
|
||||
client: &http.Client{
|
||||
Jar: jar,
|
||||
Timeout: DefaultClientTimeout,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,18 +103,6 @@ func WithReplies(b bool) *Scraper {
|
|||
return defaultScraper.WithReplies(b)
|
||||
}
|
||||
|
||||
// cookie
|
||||
func (s *Scraper) WithCookie(cookie string) *Scraper {
|
||||
s.cookie = cookie
|
||||
return s
|
||||
}
|
||||
|
||||
// x csrf token
|
||||
func (s *Scraper) WithXCsrfToken(xcsrfToken string) *Scraper {
|
||||
s.xCsrfToken = xcsrfToken
|
||||
return s
|
||||
}
|
||||
|
||||
// client timeout
|
||||
func (s *Scraper) WithClientTimeout(timeout time.Duration) *Scraper {
|
||||
s.client.Timeout = timeout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue