(
browser,
login,
user_name,
amount,
users_count,
randomize,
dont_include,
blacklist,
follow_times,
simulation,
channel,
jumps,
logger,
logfolder,
edge_followed_by,
)
| 636 | |
| 637 | |
| 638 | def get_users_through_dialog_with_graphql( |
| 639 | browser, |
| 640 | login, |
| 641 | user_name, |
| 642 | amount, |
| 643 | users_count, |
| 644 | randomize, |
| 645 | dont_include, |
| 646 | blacklist, |
| 647 | follow_times, |
| 648 | simulation, |
| 649 | channel, |
| 650 | jumps, |
| 651 | logger, |
| 652 | logfolder, |
| 653 | edge_followed_by, |
| 654 | ): |
| 655 | |
| 656 | # TODO: simulation implementation |
| 657 | |
| 658 | real_amount = amount |
| 659 | followers_list = [] |
| 660 | |
| 661 | if randomize and amount >= 3: |
| 662 | # expanding the population for better sampling distribution |
| 663 | amount = amount * 1.9 |
| 664 | try: |
| 665 | user_id = browser.execute_script( |
| 666 | "return window.__additionalData[Object.keys(window.__additionalData)[0]].data.graphql.user.id" |
| 667 | ) |
| 668 | except WebDriverException: |
| 669 | user_id = browser.execute_script( |
| 670 | "return window._sharedData.entry_data.ProfilePage[0].graphql.user.id" |
| 671 | ) |
| 672 | |
| 673 | # There are two query hash, one for followers and following, ie: |
| 674 | # t="c76146de99bb02f6415203be841dd25a",n="d04b0a864b4b54837c0d870b0e77e076" |
| 675 | if edge_followed_by: |
| 676 | # True: User requested session.follow_user_followers |
| 677 | edge_type = "edge_followed_by" |
| 678 | else: |
| 679 | # False: User requested session.follow_user_following |
| 680 | edge_type = "edge_follow" |
| 681 | |
| 682 | query_hash = get_query_hash(browser, logger, edge_followed_by) |
| 683 | |
| 684 | # check if hash is present |
| 685 | if query_hash is None: |
| 686 | logger.info("Unable to locate GraphQL query hash") |
| 687 | else: |
| 688 | logger.info("GraphQL query hash: [{}]".format(query_hash)) |
| 689 | |
| 690 | graphql_query_URL = ( |
| 691 | "view-source:https://www.instagram.com/graphql/query/?query_hash={}".format( |
| 692 | query_hash |
| 693 | ) |
| 694 | ) |
| 695 | variables = { |
no test coverage detected