当我直接传递键值(02/01/2018)可以正常工作,但是我希望一天一天传递键值(01/01/2018)没有值时。是的,我尝试了其他条件,但甚至没有再次调用self.parse(response)方法。
def parse(self,response):
if len(self.search_element) > 0:
search_param = self.search_element.pop(0)
applicantion_date = self.driver.find_elements_by_name("pmPermit..APPLICATION_DATE")[0]
applicantion_date.send_keys(search_param)
time.sleep(1)
# # click search for permits
self.driver.find_element_by_name("Button").click()
time.sleep(3)
if self.start_urls[0] in self.driver.current_url:
self.driver.back()
self.parse(response)
time.sleep(2)
else:
self.prev_items = {}
datas= self.driver.find_elements_by_xpath("//*[@class='FrameWorkBody']/tbody/tr[1]/td[2]/table/tbody/tr")
self.driver.find_element_by_xpath("//table[@class='FrameWorkBody']/tbody/tr[1]/td[2]/table/tbody/tr[4]/td[@class='Data'][1]/a").click()
for click_button in range(1,len(datas)):
if str(click_button) != '1':
self.driver.find_element_by_xpath("//table/tbody/tr[1]/td/table/tbody/tr/td[1]/table/tbody/tr[2]/td[5]").click()
time.sleep(3)
self.prev_items['Permit_hash'] = self.driver.find_element_by_xpath("//table/tbody/tr[2]/td[@class='DataBold']").text
self.prev_items['Applied']=self.driver.find_element_by_xpath("//table/tbody/tr[1]/td/table[@class='Header']/tbody/tr/td[@class='DataLabel']/table/tbody/tr[2]/td[@class='Data'][1]").text
self.prev_items['permit_type']=self.driver.find_element_by_xpath("//table/tbody/tr[2]/td/table/tbody/tr[1]/td[@class='Data'][1]/b").text
self.prev_items['permit_descrption']=self.driver.find_element_by_xpath("//table/tbody/tr[2]/td/table/tbody/tr[3]/td[@class='Data'][1]/b").text
self.prev_items['approved'] =self.driver.find_element_by_xpath("//table/tbody/tr[1]/td/table[@class='Header']/tbody/tr/td[@class='DataLabel']/table/tbody/tr[2]/td[@class='Data'][2]").text
self.prev_items['issued'] = self.driver.find_element_by_xpath("//tbody/tr[1]/td/table[@class='Header']/tbody/tr/td[@class='DataLabel']/table/tbody/tr[2]/td[@class='Data'][3]").text
self.prev_items['final'] = self.driver.find_element_by_xpath("//table[@class='Header']/tbody/tr/td[@class='DataLabel']/table/tbody/tr[2]/td[@class='Data'][4]").text
self.prev_items['Expires']=self.driver.find_element_by_xpath("//table[@class='Header']/tbody/tr/td[@class='DataLabel']/table/tbody/tr[2]/td[@class='Data'][5]").text
self.prev_items['Status']=self.driver.find_element_by_xpath("//table/tbody/tr[2]/td/table/tbody/tr[1]/td[@class='Data'][2]/b").text
self.prev_items['permit_address']=self.driver.find_element_by_xpath("//table/tbody/tr[2]/td/table/tbody/tr[2]/td[@class='Data']/b").text
applicant=self.driver.find_element_by_xpath("/html/body/center/table/tbody/tr/td/table/tbody/tr[3]/td/div/div[1]/div/table/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/b[1]").text
self.prev_items['mixed_name']=applicant
self.prev_items['mixed_subtype']="Applicant"
self.prev_items = self.viewing_type()
meta_data = self.prev_items
yield self.save_to_csv(**meta_data)
owner =self.driver.find_element_by_xpath("/html/body/center/table/tbody/tr/td/table/tbody/tr[3]/td/div/div[1]/div/table/tbody/tr[2]/td/table/tbody/tr[4]/td[2]/b").text
self.prev_items['mixed_name']=owner
self.prev_items['mixed_subtype']="Owner"
self.prev_items = self.viewing_type()
meta_data = self.prev_items
yield self.save_to_csv(**meta_data)