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,
)
| 126 | |
| 127 | |
| 128 | def 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 |
no test coverage detected