I am getting the error AttributeError: 'NoneType' object has no attribute 'findAll' everytime I run the below Python script. I have done some research and found a few posts that state perhaps I am passing 'None' when trying to find the images, which is why it errors. I still have no solution though. Any information is helpful.
Here is the full error:
Traceback (most recent call last):
File "D:\Program Files\Parser Python\Test.py", line 33, in <module>
for img in divImage.findAll('img'):
AttributeError: 'NoneType' object has no attribute 'findAll'
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.common.exceptions import TimeoutException
import os
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe'
os.environ["PATH"] += "C:\Python27\Lib\site-packages\selenium-2.53.6-py2.7.egg\selenium"
#binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(capabilities=firefox_capabilities)
# it takes forever to load the page, therefore we are setting a threshold
driver.set_page_load_timeout(5)
try:
driver.get("http://readcomiconline.to/Comic/Flashpoint/Issue-1?id=19295&readType=1")
except TimeoutException:
# never ignore exceptions silently in real world code
pass
soup2 = BeautifulSoup(driver.page_source, 'html.parser')
divImage = soup2.find('div', {"id": "divImage"})
#divImage = soup2.find('div', {"id": "containerRoot"})
# close the browser
driver.close()
for img in divImage.findAll('img'):
print img.get('src')