MCPcopy
hub / github.com/InstaPy/InstaPy / check_link

Function check_link

instapy/like_util.py:551–733  ·  view source on GitHub ↗

Check the given link if it is appropriate :param browser: The selenium webdriver instance :param post_link: :param dont_like: hashtags of inappropriate phrases :param mandatory_words: words of appropriate phrases :param ignore_if_contains: :param logger: the logger inst

(
    browser,
    post_link,
    dont_like,
    mandatory_words,
    mandatory_language,
    mandatory_character,
    is_mandatory_character,
    check_character_set,
    ignore_if_contains,
    logger,
)

Source from the content-addressed store, hash-verified

549
550
551def check_link(
552 browser,
553 post_link,
554 dont_like,
555 mandatory_words,
556 mandatory_language,
557 mandatory_character,
558 is_mandatory_character,
559 check_character_set,
560 ignore_if_contains,
561 logger,
562):
563 """
564 Check the given link if it is appropriate
565
566 :param browser: The selenium webdriver instance
567 :param post_link:
568 :param dont_like: hashtags of inappropriate phrases
569 :param mandatory_words: words of appropriate phrases
570 :param ignore_if_contains:
571 :param logger: the logger instance
572 :return: tuple of
573 boolean: True if inappropriate,
574 string: the username,
575 boolean: True if it is video media,
576 string: the message if inappropriate else 'None',
577 string: set the scope of the return value
578 """
579
580 # Check URL of the webpage, if it already is post's page, then do not
581 # navigate to it again
582 web_address_navigator(browser, post_link)
583
584 # Check if the Post is Valid/Exists
585 post_page = get_additional_data(browser)
586
587 if post_page is None:
588 logger.warning("Unavailable Page: {}".format(post_link.encode("utf-8")))
589 return True, None, None, "Unavailable Page", "Failure"
590
591 # Gets the description of the post's link and checks for the dont_like tags
592 graphql = "graphql" in post_page
593 location_name = None
594
595 if graphql:
596 media = post_page["graphql"]["shortcode_media"]
597 is_video = media["is_video"]
598 user_name = media["owner"]["username"]
599 image_text = media["edge_media_to_caption"]["edges"]
600 image_text = image_text[0]["node"]["text"] if image_text else None
601 location = media["location"]
602 location_name = location["name"] if location else None
603 media_edge_string = get_media_edge_comment_string(media)
604 # Gets all comments on media
605 comments = (
606 media[media_edge_string]["edges"]
607 if media[media_edge_string]["edges"]
608 else None

Callers 12

like_by_locationsMethod · 0.85
comment_by_locationsMethod · 0.85
like_by_tagsMethod · 0.85
like_by_usersMethod · 0.85
interact_by_usersMethod · 0.85
follow_by_locationsMethod · 0.85
follow_by_tagsMethod · 0.85
interact_by_URLMethod · 0.85
interact_by_commentsMethod · 0.85
engage_with_postsMethod · 0.85

Calls 5

web_address_navigatorFunction · 0.85
get_additional_dataFunction · 0.85
evaluate_mandatory_wordsFunction · 0.85
execute_scriptMethod · 0.80

Tested by

no test coverage detected