goinsta
goinsta copied to clipboard
Users.Next() returns false immediately or hangs
Assume something along the lines of:
user, err := i.Profiles.ByName(uname)
if err != nil {
// handle err
}
users := user.Following()
following := make([]goinsta.User, 0)
for users.Next() {
if users.Error() != nil {
// handle err
} else {
following = append(following, users.Users...)
}
}
users.Next() sometimes returns false immediately or, most of the time, just gets stuck and pegs the CPU at 100%.
Am I doing something wrong or is this part of the library currently broken due to changes made on Instagram's end?
Thanks.
Seems related to the problem regarding next_max_id
, maybe you could give #306 a try.
Tested #306 and getting even weirder behaviour .. users.Next() works once or twice most of the time - users.Users contains a list of 100 users (yay). Sometimes .Next gets stuck, sometimes it returns false and users.Users is empty.
I would like to help you with this but honstly don't know where to begin - this intermittent behaviour is very confusing. Do you think it's to do with rate-limiting?
I’ve tested the fix successfully with fairly large profiles, getting more than 1000 Users returned.
You can check for problems if you call Error() in and after your Next() for loop like so:
var users []goinsta.User
followers := profile.Following()
for followers.Next() {
err = followers.Error(); if err != nil {
log.Fatal(err)
}
users = append(users, followers.Users...)
}
err = followers.Error(); if err != nil {
log.Fatal(err)
}
I've the same problem, here is my error: 2020/12/10 02:09:10 json: cannot unmarshal number into Go struct field Users.next_max_id of type string