Instapy: list index out of range - Class g47SY - Sorry, this page isn't available

Created on 23 Jul 2018  路  7Comments  路  Source: timgrossmann/InstaPy

Gentlemen - looks like a lot of people are getting this one. It happens when the Instagram throws an error - "Sorry, this page is not available" (like for this user - https://www.instagram.com/dj5150_ktownoakland/ ) . Meaning the user does not exist. That is at least one case I've encountered. Happens once every few hours or so if using follow followers.

Summoning the Great Wizards @uluQulu and @sionking and @timgrossmann :)
11untitled

Bunch of issues opened for this one but without a definite fix:
https://github.com/timgrossmann/InstaPy/issues/2340
https://github.com/timgrossmann/InstaPy/issues/2330
https://github.com/timgrossmann/InstaPy/issues/2212
https://github.com/timgrossmann/InstaPy/issues/2190
https://github.com/timgrossmann/InstaPy/issues/2481

wontfix

Most helpful comment

Annyone? :)

All 7 comments

Annyone? :)

So no one knows how to fix this?

On util.py file, replace:

followers_count = format_number((browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")[1].text))

With:

topCount_elements = browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")
if topCount_elements:
    followers_count = format_number(topCount_elements[1].text)
else:
    logger.error("Failed to get followers count of '{}'  ~empty list".format(username))
    followers_count = None

And, replace:

following_count = format_number(browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")[2].text)

With:

topCount_elements = browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")
if topCount_elements:
    following_count = format_number(topCount_elements[2].text)
else:
    logger.error("Failed to get following count of '{}'  ~empty list".format(username))
    following_count = None

On unfollow_util.py file, replace :

allfollowers = format_number((browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")[1].text))

With:

topCount_elements = browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")
if topCount_elements:
    allfollowers = format_number(topCount_elements[1].text)
else:
    logger.error("Error occured during getting the followers count of '{}'  ~empty list".format(username))
    allfollowers = None

And replace:

allfollowing = format_number((browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")[2].text))

With:

topCount_elements = browser.find_elements_by_xpath(
    "//span[contains(@class,'g47SY')]")
if topCount_elements:
    allfollowing = format_number(topCount_elements[2].text)
else:
    logger.error("Error occured during getting the following count of '{}'  ~empty list".format(username))
    allfollowing = None

Hope it helps!
Based on @uluQulu proposal!

This fixed the problem for me. Thanks!

@Floflokiki - thank you, that fixed it for me as well!

Thanks for the help this fix should be merged :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. > If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tibor picture tibor  路  3Comments

harrypython picture harrypython  路  3Comments

CharlesCCC picture CharlesCCC  路  3Comments

seuraltimez picture seuraltimez  路  3Comments

Naramsim picture Naramsim  路  3Comments