MCPcopy
hub / github.com/InstaPy/InstaPy / validate_username

Function validate_username

instapy/util.py:128–489  ·  view source on GitHub ↗

Check if we can interact with the user

(
    browser,
    username_or_link,
    own_username,
    ignore_users,
    blacklist,
    potency_ratio,
    delimit_by_numbers,
    max_followers,
    max_following,
    min_followers,
    min_following,
    min_posts,
    max_posts,
    skip_private,
    skip_private_percentage,
    skip_public,
    skip_public_percentage,
    skip_no_profile_pic,
    skip_no_profile_pic_percentage,
    skip_business,
    skip_non_business,
    skip_business_percentage,
    skip_business_categories,
    dont_skip_business_categories,
    skip_bio_keyword,
    mandatory_bio_keywords,
    logger,
    logfolder,
)

Source from the content-addressed store, hash-verified

126
127
128def validate_username(
129 browser,
130 username_or_link,
131 own_username,
132 ignore_users,
133 blacklist,
134 potency_ratio,
135 delimit_by_numbers,
136 max_followers,
137 max_following,
138 min_followers,
139 min_following,
140 min_posts,
141 max_posts,
142 skip_private,
143 skip_private_percentage,
144 skip_public,
145 skip_public_percentage,
146 skip_no_profile_pic,
147 skip_no_profile_pic_percentage,
148 skip_business,
149 skip_non_business,
150 skip_business_percentage,
151 skip_business_categories,
152 dont_skip_business_categories,
153 skip_bio_keyword,
154 mandatory_bio_keywords,
155 logger,
156 logfolder,
157):
158 """Check if we can interact with the user"""
159
160 # some features may not provide `username` and in those cases we will
161 # get it from post's page.
162 if "/" in username_or_link:
163 link = username_or_link # if there is a `/` in `username_or_link`,
164 # then it is a `link`
165
166 # check URL of the webpage, if it already is user's profile page,
167 # then do not navigate to it again
168 web_address_navigator(browser, link)
169
170 try:
171 username = browser.execute_script(
172 "return window._sharedData.entry_data."
173 "PostPage[0].graphql.shortcode_media.owner.username"
174 )
175
176 except WebDriverException:
177 try:
178 browser.execute_script("location.reload()")
179 update_activity(browser, state=None)
180
181 username = browser.execute_script(
182 "return window._sharedData.entry_data."
183 "PostPage[0].graphql.shortcode_media.owner.username"
184 )
185

Callers 1

validate_user_callMethod · 0.85

Calls 7

web_address_navigatorFunction · 0.85
update_activityFunction · 0.85
get_relationship_countsFunction · 0.85
truncate_floatFunction · 0.85
getUserDataFunction · 0.85
evaluate_mandatory_wordsFunction · 0.85
execute_scriptMethod · 0.80

Tested by

no test coverage detected