Jun-02-2017, 03:29 AM
I am trying to list out my facebook membership groups using selenium, but i cant without bypassing this javascript box. The
[attachment=189]
attempting to proceed without taking care of this box causes
[attachment=189]
attempting to proceed without taking care of this box causes
Error:Traceback (most recent call last):
File "test2.py", line 52, in <module>
soup = BeautifulSoup(r.page_source, 'lxml')
AttributeError: 'NoneType' object has no attribute 'page_source'
Then i added the browser.switch_to_alert().accept() but now i get a no alert open errorError: File "test2.py", line 50, in <module>
alert.accept()
File "/home/metulburr/.local/lib/python2.7/site-packages/selenium/webdriver/common/alert.py", line 90, in accept
self.driver.execute(Command.ACCEPT_ALERT)
File "/home/metulburr/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/home/metulburr/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoAlertPresentException: Message: no alert open
(Session info: chrome=58.0.3029.110)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-78-generic x86_64)
r = browser.get('https://www.facebook.com/groups/?category=groups') time.sleep(DELAY) alert = browser.switch_to_alert() alert.accept() for _ in range(100): #scroll to make all groups visible browser.execute_script("window.scrollTo(0, document.body.scrollHeight);") soup = BeautifulSoup(r.page_source, 'lxml') print(soup.find("div", {"id": "group-discover-card-right-columnmembership"}))Usually i would just find the XPath to the submit/ok button and select it but with the method i dont think you can see the source of this.