MCPcopy
hub / github.com/InstaPy/InstaPy / dialog_username_extractor

Function dialog_username_extractor

instapy/unfollow_util.py:835–861  ·  view source on GitHub ↗

Extract username of a follow button from a dialog box

(buttons)

Source from the content-addressed store, hash-verified

833
834
835def dialog_username_extractor(buttons):
836 """Extract username of a follow button from a dialog box"""
837
838 if not isinstance(buttons, list):
839 buttons = [buttons]
840
841 person_list = []
842 for person in buttons:
843 if person and hasattr(person, "text") and person.text:
844 try:
845 xpath = read_xpath(dialog_username_extractor.__name__, "person")
846 element_by_xpath = person.find_element(By.XPATH, xpath)
847 elements_by_tag_name = element_by_xpath.find_elements(By.TAG_NAME, "a")[
848 0
849 ].text
850
851 if elements_by_tag_name == "":
852 elements_by_tag_name = element_by_xpath.find_elements(
853 By.TAG_NAME, "a"
854 )[1].text
855
856 person_list.append(elements_by_tag_name)
857 except IndexError:
858 print("how many?")
859 pass # Element list is too short to have a [1] element
860
861 return person_list
862
863
864def follow_through_dialog(

Callers

nothing calls this directly

Calls 1

read_xpathFunction · 0.85

Tested by

no test coverage detected