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

Bad XPath with -p/--person option #17

Open
D4m13n-contrib opened this issue Nov 7, 2024 · 2 comments
Open

Bad XPath with -p/--person option #17

D4m13n-contrib opened this issue Nov 7, 2024 · 2 comments

Comments

@D4m13n-contrib
Copy link

Hi,

When I try to use the option -p/--person I got a Python exception with Selenium during the parsing of the page :

$> python phunter.py -p +33666666666
                                                                                                                                                              
                     _._     _,-'""'-._
                    (,-.`._,'(       |\`-/|               q-p
                        `-.-' \ )-`( , o o)              /   \
                            `-    \`_`"'-               (     )
                                                         `-(-'
                                                            )

                            :-----------------Phunter-----------------:
                            |    by Norze ~ Phone number OSINT Tool   |
                            :-----------------------------------------:

[?] What's your browser? Chrome or Firefox? (c/f): f
[>] Driver setup completed

[!] You have 10s for accept
Traceback (most recent call last):
  File "/home/damien/Desktop/Phunter/phunter.py", line 8, in <module>
    asyncio.run(parser())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/damien/Desktop/Phunter/lib/cli.py", line 104, in parser
    Annuaire.annuaire(args.person)
  File "/home/damien/Desktop/Phunter/lib/annuaire.py", line 53, in annuaire
    driver.find_element(By.XPATH, '//*[@id="form_motor_pagesjaunes"]/div/div[2]/div/button').click()
  File "/home/damien/Desktop/Phunter/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 766, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
  File "/home/damien/Desktop/Phunter/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 380, in execute
    self.error_handler.check_response(response)
  File "/home/damien/Desktop/Phunter/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id="form_motor_pagesjaunes"]/div/div[2]/div/button; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:511:5
dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16

To solve this issue, I suggest you to modify the XPath like this :

diff --git a/lib/annuaire.py b/lib/annuaire.py
index e0e1af6..790868d 100644
--- a/lib/annuaire.py
+++ b/lib/annuaire.py
@@ -50,7 +50,7 @@ class Annuaire:
         driver.find_element(By.XPATH, '//*[@id="quoiqui"]').send_keys(p_n)
         sleep(1)
 
-        driver.find_element(By.XPATH, '//*[@id="form_motor_pagesjaunes"]/div/div[2]/div/button').click()
+        driver.find_element(By.XPATH, '//*[@id="findId"]').click()
         sleep(1)
 
         try:

Note: only tested with Firefox web browser.

@DrAnonym666
Copy link

@D4m13n-contrib

and then it works??

@D4m13n-contrib
Copy link
Author

and then it works??

Yes it works for me:

$> python phunter.py -p +33666666666
                                                                                                                                                              
                     _._     _,-'""'-._
                    (,-.`._,'(       |\`-/|               q-p
                        `-.-' \ )-`( , o o)              /   \
                            `-    \`_`"'-               (     )
                                                         `-(-'
                                                            )

                            :-----------------Phunter-----------------:
                            |    by Norze ~ Phone number OSINT Tool   |
                            :-----------------------------------------:

[?] What's your browser? Chrome or Firefox? (c/f): f
[>] Driver setup completed

[!] You have 10s for accept

[>] 2 results found in PageBlanche
[=] Link => https://www.pagesjaunes.fr/annuaireinverse/recherche?quoiqui=33666666666&univers=annuaireinverse&idOu=

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

2 participants