MCPcopy
hub / github.com/InstaPy/InstaPy / get_number_of_posts

Function get_number_of_posts

instapy/util.py:1148–1172  ·  view source on GitHub ↗

Get the number of posts from the profile screen

(browser)

Source from the content-addressed store, hash-verified

1146
1147
1148def get_number_of_posts(browser):
1149 """Get the number of posts from the profile screen"""
1150 try:
1151 num_of_posts = getUserData(
1152 "graphql.user.edge_owner_to_timeline_media.count", browser
1153 )
1154 except WebDriverException:
1155 try:
1156 num_of_posts_txt = browser.find_element(
1157 By.XPATH, read_xpath(get_number_of_posts.__name__, "num_of_posts_txt")
1158 ).text
1159
1160 except NoSuchElementException:
1161 num_of_posts_txt = browser.find_element(
1162 By.XPATH,
1163 read_xpath(
1164 get_number_of_posts.__name__, "num_of_posts_txt_no_such_element"
1165 ),
1166 ).text
1167
1168 num_of_posts_txt = num_of_posts_txt.replace(" ", "")
1169 num_of_posts_txt = num_of_posts_txt.replace(",", "")
1170 num_of_posts = int(num_of_posts_txt)
1171
1172 return num_of_posts
1173
1174
1175def get_relationship_counts(browser, username, logger):

Callers 2

get_links_for_usernameFunction · 0.85
extract_informationFunction · 0.85

Calls 2

getUserDataFunction · 0.85
read_xpathFunction · 0.85

Tested by

no test coverage detected