I don't understand why this code is not entering the parse method. It is pretty similar to the basic spider examples from the doc: http://doc.scrapy.org/en/latest/topics/spiders.html And I'm pretty sure this worked earlier in the day... Not sure if I modified something or not..
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from scrapy.spider import Spider
from scrapy.selector import HtmlXPathSelector
from scrapy import log
from scrapy.selector import Selector
class jobSpider(Spider):
name='jobSpider'
wd = webdriver.Chrome()
wd.get("some url")
wd.switch_to_frame("cible")
def parse(self, response):
log.start()
wait = WebDriverWait(wd, 10).until(
(EC.visibility_of_element_located((By.ID, 'blocResultat'))))
print(wd.page_source)
stuff=Selector(text=wd.page_source).xpath('//a[contains(@onclick,"win=window.o pen(\'JobOffs")]').extract()
print(stuff)
Your
parse(self, response):
method is not part of thejobSpider
class. If you look at the Scrapy documentation you'll see that theparse
method needs to be a method of your spider class.Also, you need to reference the class data in your
parse
method by using theself.
prefix on any data in the class.Additionally, you're missing the start_urls list on your spider. Without it, the spider won't know where to start, and will do nothing.