MCPcopy
hub / github.com/InstaPy/InstaPy / get_follow_requests

Function get_follow_requests

instapy/unfollow_util.py:1591–1645  ·  view source on GitHub ↗

Get follow requests from instagram access tool list

(browser, amount, sleep_delay, logger, logfolder)

Source from the content-addressed store, hash-verified

1589
1590
1591def get_follow_requests(browser, amount, sleep_delay, logger, logfolder):
1592 """Get follow requests from instagram access tool list"""
1593
1594 user_link = "https://www.instagram.com/accounts/access_tool/current_follow_requests"
1595 web_address_navigator(browser, user_link)
1596
1597 list_of_users = []
1598 view_more_button_exist = True
1599 view_more_clicks = 0
1600 view_more_button = None
1601
1602 while (
1603 len(list_of_users) < amount
1604 and view_more_clicks < 750
1605 and view_more_button_exist
1606 ):
1607 sleep(4)
1608 list_of_users = browser.find_elements(
1609 By.XPATH, read_xpath(get_follow_requests.__name__, "list_of_users")
1610 )
1611
1612 if len(list_of_users) == 0:
1613 logger.info("There are not outgoing follow requests")
1614 break
1615
1616 try:
1617 view_more_button = browser.find_element(
1618 By.XPATH, read_xpath(get_follow_requests.__name__, "view_more_button")
1619 )
1620 except NoSuchElementException:
1621 view_more_button_exist = False
1622
1623 if view_more_button_exist:
1624 logger.info(
1625 "Found '{}' outgoing follow requests, Going to ask for more...".format(
1626 len(list_of_users)
1627 )
1628 )
1629 click_element(browser, view_more_button)
1630 view_more_clicks += 1
1631
1632 users_to_unfollow = []
1633
1634 for user in list_of_users:
1635 users_to_unfollow.append(user.text)
1636 if len(users_to_unfollow) == amount:
1637 break
1638
1639 logger.info(
1640 "Found '{}' outgoing follow requests '{}'".format(
1641 len(users_to_unfollow), users_to_unfollow
1642 )
1643 )
1644
1645 return users_to_unfollow
1646
1647
1648def set_followback_in_pool(username, person, person_id, logtime, logger, logfolder):

Callers 1

Calls 4

web_address_navigatorFunction · 0.85
sleepFunction · 0.85
read_xpathFunction · 0.85
click_elementFunction · 0.85

Tested by

no test coverage detected