Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while getting following #42

Open
soxoj opened this issue Oct 28, 2023 · 3 comments
Open

Error while getting following #42

soxoj opened this issue Oct 28, 2023 · 3 comments

Comments

@soxoj
Copy link
Contributor

soxoj commented Oct 28, 2023

$ GitFive user soxoj

Account is PEA : False
Traceback (most recent call last):
  File "/Users/account/.local/bin/GitFive", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/gitfive.py", line 15, in main
    parse_args()
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/cli.py", line 51, in parse_args
    trio.run(username_mod.hunt, args.username, args.json)
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/trio/_core/_run.py", line 1946, in run
    raise runner.main_task_outcome.error
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/modules/username_mod.py", line 150, in hunt
    runner.target.potential_friends = await close_friends.guess(runner)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/close_friends.py", line 43, in guess
    new_pea_cache = await pea.analyze(runner, usernames)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/pea.py", line 25, in analyze
    async with trio.open_nursery() as nursery:
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/trio/_core/_run.py", line 813, in __aexit__
    raise combined_error_from_nursery
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/pea.py", line 39, in is_pea
    not await is_followed_or_following_a_lot(runner, username):
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/account/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/pea.py", line 54, in is_followed_or_following_a_lot
    followers = int(followers.text.replace('k', '00').replace('.', '').split(' ')[0].strip('\n')) if followers else 0
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
@mxrch
Copy link
Owner

mxrch commented Oct 28, 2023

I will kms why do you get all the errors 😭
They maybe changed a few things very recently, I'll try to take a look

soxoj added a commit to soxoj/GitFive that referenced this issue Oct 28, 2023
@novitae
Copy link

novitae commented Jan 1, 2024

Im also getting it 🥺 But not coming from the same file

Account is PEA : False
Traceback (most recent call last):
  File "/Users/n/.local/bin/gitfive", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/gitfive.py", line 15, in main
    parse_args()
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/cli.py", line 51, in parse_args
    trio.run(username_mod.hunt, args.username, args.json)
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/trio/_core/_run.py", line 1946, in run
    raise runner.main_task_outcome.error
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/modules/username_mod.py", line 150, in hunt
    runner.target.potential_friends = await close_friends.guess(runner)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/close_friends.py", line 36, in guess
    target["followers"] = await social.get_follows(runner, "followers")
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/social.py", line 23, in get_follows
    followers = int(followers.text.replace('k', '00').replace('.', '').split(' ')[0].strip('\n')) if followers else 0
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

@novitae
Copy link

novitae commented Jan 1, 2024

Mine is coming from their recent add of the followed by <...> under the informations of someone. If I print the followers variable from here:

followers = body.find("a", href=f"/{runner.target.username}?tab={to_scrape}")

It prints that before raising the error:

<a class="Link--secondary no-underline no-wrap pl-1" data-analytics-event='{"category":"Mutual Followers","action":"View follows","label":"current_user_id:xxxx;logged_in:true;user:xxxx"}' href="/USERNAME?tab=followers">
    Followed by <span class="Truncate-text text-bold">USER I FOLLOW</span>
</a>
Traceback (most recent call last):
  File "/Users/n/.local/bin/gitfive", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/gitfive.py", line 15, in main
    parse_args()
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/cli.py", line 51, in parse_args
    trio.run(username_mod.hunt, args.username, args.json)
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/trio/_core/_run.py", line 1946, in run
    raise runner.main_task_outcome.error
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/modules/username_mod.py", line 150, in hunt
    runner.target.potential_friends = await close_friends.guess(runner)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/close_friends.py", line 36, in guess
    target["followers"] = await social.get_follows(runner, "followers")
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/n/.local/pipx/venvs/gitfive/lib/python3.11/site-packages/gitfive/lib/social.py", line 24, in get_follows
    followers = int(followers.text.replace('k', '00').replace('.', '').split(' ')[0].strip('\n')) if followers else 0
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

I was able to fix it by replacing the line I cited upper by:

    followers = body.find(lambda tag: tag.name == "a" 
                                     and tag.get("href") == f"/{runner.target.username}?tab={to_scrape}" 
                                     and "pl-1" not in tag.get("class", []) 
                                     and "data-analytics-event" not in tag.attrs)

mxrch added a commit that referenced this issue Feb 27, 2024
Fixed followers/following extraction errors (#42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants