def parse(self, response):
    sel = Selector(response)
    indexlist = list(map((lambda x: x.replace(' ', '').replace('.', '')), sel.xpath('//table[@id="obsTable"]/thead/tr/th/text()').extract()))
    date = re.match('.*(\\d{4}\\/\\d{1,2}\\/\\d{1,2}).*', response.url).group(1)
    datatable = sel.xpath('//tr[@class="no-metars"]')
    for each in datatable:
        item = ClimatespiderItem()
        item['area'] = re.match('.*history/(.*)/2\\d{3}/.*', response.url).group(1)
        if (len(indexlist) == 13):
            item['the_date'] = date
            item['the_time'] = parse(each.xpath('td[1]/text()').extract()[0]).strftime('%H:%M')
            item['qx_Humidity'] = each.xpath('td[5]/text()').extract()[0]
            item['qx_WindDir'] = each.xpath('td[8]/text()').extract()[0]
            item['qx_Precip'] = each.xpath('td[11]/text()').extract()[0]
            item['qx_Events'] = each.xpath('td[12]/text()').extract()[0].strip()
            try:
                item['qx_Condition'] = each.xpath('td[13]/text()').extract()[0]
            except Exception as e:
                item['qx_Condition'] = ''
            try:
                item['qx_Temp'] = each.xpath('td[2]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Temp'] = each.xpath('td[2]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_WindChill_HeatIndex'] = each.xpath('td[3]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindChill_HeatIndex'] = each.xpath('td[3]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_DewPoint'] = each.xpath('td[4]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_DewPoint'] = each.xpath('td[4]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_Pressure'] = each.xpath('td[6]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Pressure'] = each.xpath('td[6]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_Visibility'] = each.xpath('td[7]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Visibility'] = each.xpath('td[7]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_WindSpeed'] = each.xpath('td[9]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindSpeed'] = each.xpath('td[9]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_GustSpeed'] = each.xpath('td[10]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_GustSpeed'] = each.xpath('td[10]/text()').extract()[0].strip().replace('-', '')
            (yield item)
        else:
            item['the_date'] = date
            item['the_time'] = parse(each.xpath('td[1]/text()').extract()[0]).strftime('%H:%M')
            item['qx_Humidity'] = each.xpath('td[4]/text()').extract()[0]
            item['qx_WindDir'] = each.xpath('td[7]/text()').extract()[0]
            item['qx_Precip'] = each.xpath('td[10]/text()').extract()[0]
            item['qx_Events'] = each.xpath('td[11]/text()').extract()[0].strip()
            try:
                item['qx_Condition'] = each.xpath('td[12]/text()').extract()[0]
            except Exception as e:
                item['qx_Condition'] = ''
            try:
                item['qx_Temp'] = each.xpath('td[2]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Temp'] = each.xpath('td[2]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_DewPoint'] = each.xpath('td[3]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_DewPoint'] = each.xpath('td[3]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_Pressure'] = each.xpath('td[5]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Pressure'] = each.xpath('td[5]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_Visibility'] = each.xpath('td[6]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Visibility'] = each.xpath('td[6]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_WindSpeed'] = each.xpath('td[8]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindSpeed'] = each.xpath('td[8]/text()').extract()[0].strip().replace('-', '')
            try:
                item['qx_GustSpeed'] = each.xpath('td[9]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_GustSpeed'] = each.xpath('td[9]/text()').extract()[0].strip().replace('-', '')
            (yield item)
def parse(self, response):
    sel = Selector(response)
    indexlist = list(map((lambda x: x.replace(' ', ).replace('.', )), sel.xpath('//table[@id="obsTable"]/thead/tr/th/text()').extract()))
    date = re.match('.*(\\d{4}\\/\\d{1,2}\\/\\d{1,2}).*', response.url).group(1)
    datatable = sel.xpath('//tr[@class="no-metars"]')
    for each in datatable:
        item = ClimatespiderItem()
        item['area'] = re.match('.*history/(.*)/2\\d{3}/.*', response.url).group(1)
        if (len(indexlist) == 13):
            item['the_date'] = date
            item['the_time'] = parse(each.xpath('td[1]/text()').extract()[0]).strftime('%H:%M')
            item['qx_Humidity'] = each.xpath('td[5]/text()').extract()[0]
            item['qx_WindDir'] = each.xpath('td[8]/text()').extract()[0]
            item['qx_Precip'] = each.xpath('td[11]/text()').extract()[0]
            item['qx_Events'] = each.xpath('td[12]/text()').extract()[0].strip()
            try:
                item['qx_Condition'] = each.xpath('td[13]/text()').extract()[0]
            except Exception as e:
                item['qx_Condition'] = 
            try:
                item['qx_Temp'] = each.xpath('td[2]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Temp'] = each.xpath('td[2]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_WindChill_HeatIndex'] = each.xpath('td[3]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindChill_HeatIndex'] = each.xpath('td[3]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_DewPoint'] = each.xpath('td[4]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_DewPoint'] = each.xpath('td[4]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_Pressure'] = each.xpath('td[6]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Pressure'] = each.xpath('td[6]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_Visibility'] = each.xpath('td[7]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Visibility'] = each.xpath('td[7]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_WindSpeed'] = each.xpath('td[9]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindSpeed'] = each.xpath('td[9]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_GustSpeed'] = each.xpath('td[10]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_GustSpeed'] = each.xpath('td[10]/text()').extract()[0].strip().replace('-', )
            (yield item)
        else:
            item['the_date'] = date
            item['the_time'] = parse(each.xpath('td[1]/text()').extract()[0]).strftime('%H:%M')
            item['qx_Humidity'] = each.xpath('td[4]/text()').extract()[0]
            item['qx_WindDir'] = each.xpath('td[7]/text()').extract()[0]
            item['qx_Precip'] = each.xpath('td[10]/text()').extract()[0]
            item['qx_Events'] = each.xpath('td[11]/text()').extract()[0].strip()
            try:
                item['qx_Condition'] = each.xpath('td[12]/text()').extract()[0]
            except Exception as e:
                item['qx_Condition'] = 
            try:
                item['qx_Temp'] = each.xpath('td[2]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Temp'] = each.xpath('td[2]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_DewPoint'] = each.xpath('td[3]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_DewPoint'] = each.xpath('td[3]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_Pressure'] = each.xpath('td[5]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Pressure'] = each.xpath('td[5]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_Visibility'] = each.xpath('td[6]/span/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_Visibility'] = each.xpath('td[6]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_WindSpeed'] = each.xpath('td[8]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_WindSpeed'] = each.xpath('td[8]/text()').extract()[0].strip().replace('-', )
            try:
                item['qx_GustSpeed'] = each.xpath('td[9]/span[1]/span[@class="wx-value"]/text()').extract()[0]
            except Exception as e:
                item['qx_GustSpeed'] = each.xpath('td[9]/text()').extract()[0].strip().replace('-', )
            (yield item)