Fix search again
This commit is contained in:
parent
61f2b78e2b
commit
ed0a19c7de
2 changed files with 2 additions and 13 deletions
|
|
@ -3,7 +3,6 @@ package twitterscraper_test
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
twitterscraper "github.com/n0madic/twitter-scraper"
|
twitterscraper "github.com/n0madic/twitter-scraper"
|
||||||
|
|
@ -31,9 +30,6 @@ func TestFetchSearchCursor(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(cursor, "scroll:") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if cursor == "" {
|
if cursor == "" {
|
||||||
t.Fatal("Expected search cursor is empty")
|
t.Fatal("Expected search cursor is empty")
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +46,7 @@ func TestGetSearchProfiles(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
searchScraper.SetSearchMode(twitterscraper.SearchUsers)
|
||||||
for profile := range searchScraper.SearchProfiles(context.Background(), "Twitter", maxProfilesNbr) {
|
for profile := range searchScraper.SearchProfiles(context.Background(), "Twitter", maxProfilesNbr) {
|
||||||
if profile.Error != nil {
|
if profile.Error != nil {
|
||||||
t.Error(profile.Error)
|
t.Error(profile.Error)
|
||||||
|
|
@ -79,6 +76,7 @@ func TestGetSearchTweets(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
searchScraper.SetSearchMode(twitterscraper.SearchLatest)
|
||||||
for tweet := range searchScraper.SearchTweets(context.Background(), "twitter", maxTweetsNbr) {
|
for tweet := range searchScraper.SearchTweets(context.Background(), "twitter", maxTweetsNbr) {
|
||||||
if tweet.Error != nil {
|
if tweet.Error != nil {
|
||||||
t.Error(tweet.Error)
|
t.Error(tweet.Error)
|
||||||
|
|
|
||||||
9
util.go
9
util.go
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -82,10 +81,6 @@ func getUserTimeline(ctx context.Context, query string, maxProfilesNbr int, fetc
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(next, "scroll:") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, profile := range profiles {
|
for _, profile := range profiles {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|
@ -131,10 +126,6 @@ func getTweetTimeline(ctx context.Context, query string, maxTweetsNbr int, fetch
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(next, "scroll:") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tweet := range tweets {
|
for _, tweet := range tweets {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue