feat: x.com migration + public API for cookie-based auth
- migrate all API URLs from twitter.com to x.com - add SetBearerToken, SetHTTPClient, SetLoggedIn public methods - accept 202/204 status codes in handleResponse - module path -> src.cultist.club/lain/twitter-scrapper
This commit is contained in:
parent
76cb95cd3e
commit
34db837a9e
19 changed files with 75 additions and 63 deletions
12
auth.go
12
auth.go
|
|
@ -19,9 +19,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
loginURL = "https://api.twitter.com/1.1/onboarding/task.json"
|
||||
logoutURL = "https://api.twitter.com/1.1/account/logout.json"
|
||||
oAuthURL = "https://api.twitter.com/oauth2/token"
|
||||
loginURL = "https://api.x.com/1.1/onboarding/task.json"
|
||||
logoutURL = "https://api.x.com/1.1/account/logout.json"
|
||||
oAuthURL = "https://api.x.com/oauth2/token"
|
||||
// Doesn't require x-client-transaction-id header in auth. x-rate-limit-limit: 2000
|
||||
bearerToken1 = "AAAAAAAAAAAAAAAAAAAAAFQODgEAAAAAVHTp76lzh3rFzcHbmHVvQxYYpTw%3DckAlMINMjmCwxUcaXbAN4XqJVdgMJaHqNOFgPMK0zN1qLqLQCF"
|
||||
// HOTFIX: Returns 404 error; Requires x-client-transaction-id header in auth.
|
||||
|
|
@ -152,7 +152,7 @@ func (s *Scraper) getFlowToken(data map[string]interface{}) (string, error) {
|
|||
func (s *Scraper) IsLoggedIn() bool {
|
||||
s.isLogged = true
|
||||
s.setBearerToken(bearerToken1)
|
||||
req, err := http.NewRequest("GET", "https://api.twitter.com/1.1/account/verify_credentials.json", nil)
|
||||
req, err := http.NewRequest("GET", "https://api.x.com/1.1/account/verify_credentials.json", nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
@ -444,7 +444,7 @@ func (s *Scraper) SetAuthToken(token AuthToken) {
|
|||
Name: "auth_token",
|
||||
Value: token.Token,
|
||||
Path: "",
|
||||
Domain: "twitter.com",
|
||||
Domain: "x.com",
|
||||
Expires: expires,
|
||||
RawExpires: "",
|
||||
MaxAge: 0,
|
||||
|
|
@ -457,7 +457,7 @@ func (s *Scraper) SetAuthToken(token AuthToken) {
|
|||
Name: "ct0",
|
||||
Value: token.CSRFToken,
|
||||
Path: "",
|
||||
Domain: "twitter.com",
|
||||
Domain: "x.com",
|
||||
Expires: expires,
|
||||
RawExpires: "",
|
||||
MaxAge: 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue