python 3.x - 'NoneType' object is not iterable in loop -
i assuming making mistake in assigning links equal driver.get statement. need loop within page until grabs links messing somewhere. keep getting error of "typeerror: 'nonetype' object not iterable" in line "for link in links:"
import requests bs4 import beautifulsoup selenium import webdriver import csv b = open('csv/homedepotfridges.csv', 'w', newline='') = csv.writer(b,delimiter=',') driver = webdriver.phantomjs() links = driver.get('https://www.homedepot.ca/en/home/categories/appliances/refrigerators-and-freezers/refrigerators.html') link in links: name = driver.find_element_by_class_name('product-name') model = driver.find_element_by_class_name('product-model') price = driver.find_element_by_class_name('product-display-price') detail = driver.find_element_by_class_name('js-detail-link') x, y, z, q in zip(name, model, price, detail): c= (x.text, y.text, z.text, q.get_attribute("href")) print (x.text, y.text, z.text, q.get_attribute("href")) a.writerow(c) b.close()
selenium webdrivers don't return get
method, , in fact get
method may return before web page has started loading. see documentation waiting content.
Comments
Post a Comment