def parse(self, response):
     print('china trust:%s' % response)
     item = CurrencyItem(name='china bank', updated_time=datetime.now())
     currency_table = response.xpath('//*[@id="mainTable"]')
     jpy = []
     for row in currency_table.xpath('tr'):
         currencies = [
             col.xpath('normalize-space(text())').extract_first('0')
             for col in row.xpath('td')
         ]
         if re.match('\W*JPY\W*', currencies[0]):
             jpy = currencies[2]
     item['jpy'] = jpy
     yield item
 def parse(self, response):
     print('response:%s' % response)
     item = CurrencyItem(name='First bank', updated_time=datetime.now())
     table = response.xpath('//*[@id="table1"]//tr')
     jpy = ''
     for row in table:
         list = []
         for col in row.xpath('td'):
             if not col.xpath('img').extract_first() is None:
                 country = col.xpath('img/@alt').extract_first()
                 list.append(country)
                 continue
             currency = col.xpath('normalize-space(text())').extract_first(
                 "")
             list.append(currency)
         if len(list) <= 0:
             continue
         if re.match('現鈔'.decode('utf-8'), list[1]):
             print list[0]
             if re.match('\W*JPY\W*', list[0]):
                 jpy = list[3]
                 item['currency'] = jpy
                 item['coin_type'] = 'jpy'
                 item['flow_type'] = 'cash_selling'
                 yield item
             if re.match('\W*USD\W*', list[0]):
                 usd = list[3]
                 item['currency'] = usd
                 item['coin_type'] = 'usd'
                 item['flow_type'] = 'cash_selling'
                 yield item
             if re.match('\W*THB\W*', list[0]):
                 thb = list[3]
                 item['currency'] = thb
                 item['coin_type'] = 'thb'
                 item['flow_type'] = 'cash_selling'
                 yield item
             if re.match('\W*EUR\W*', list[0]):
                 eur = list[3]
                 item['currency'] = eur
                 item['coin_type'] = 'eur'
                 item['flow_type'] = 'cash_selling'
                 yield item
예제 #3
0
 def parse(self, response):
     print('response:%s' % response)
     item = CurrencyItem(name='Taiwan bank', updated_time=datetime.now())
     currency_table = response.xpath('//div[1]/main/div[3]/table/tbody')
     jpy = ''
     for row in currency_table.xpath('tr'):
         currencies = []
         for col in row.xpath('td'):
             country_block = col.xpath('div')
             if not country_block.extract_first() is None:
                 country = country_block.xpath(
                     'div[@class="visible-phone print_hide"]/text()[normalize-space()]'
                 ).extract_first("")
                 currencies.append(country)
                 continue
             c = col.xpath('text()').extract_first("0")
             currencies.append(c)
         if re.match('\W*JPY\W*', currencies[0]):
             jpy = currencies[2]
             item['currency'] = jpy
             item['coin_type'] = 'jpy'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*THB\W*', currencies[0]):
             thb = currencies[2]
             item['currency'] = thb
             item['coin_type'] = 'thb'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*USD\W*', currencies[0]):
             usd = currencies[2]
             item['currency'] = usd
             item['coin_type'] = 'usd'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*EUR\W*', currencies[0]):
             eur = currencies[2]
             item['currency'] = eur
             item['coin_type'] = 'eur'
             item['flow_type'] = 'cash_selling'
             yield item
 def parse(self, response):
     print('response:%s' % response)
     item = CurrencyItem(name='Taiwan bank', updated_time=datetime.now())
     currency_table = response.xpath('//div[1]/main/div[4]/table/tbody')
     jpy = ''
     for row in currency_table.xpath('tr'):
         currencies = []
         for col in row.xpath('td'):
             country_block = col.xpath('div')
             if not country_block.extract_first() is None:
                 country = country_block.xpath(
                     'div[@class="visible-phone print_hide"]/text()[normalize-space()]'
                 ).extract_first("")
                 currencies.append(country)
                 continue
             c = col.xpath('text()').extract_first("0")
             currencies.append(c)
         if re.match('\W*JPY\W*', currencies[0]):
             jpy = currencies[2]
     item['jpy'] = jpy
     yield item
예제 #5
0
 def parse(self, response):
     print('response:%s' % response)
     item = CurrencyItem(name='First bank', updated_time=datetime.now())
     table = response.xpath('//*[@id="table1"]//tr')
     jpy = ''
     for row in table:
         list = []
         for col in row.xpath('td'):
             if not col.xpath('img').extract_first() is None:
                 country = col.xpath('img/@alt').extract_first()
                 list.append(country)
                 continue
             currency = col.xpath('normalize-space(text())').extract_first(
                 "")
             list.append(currency)
         if len(list) <= 0:
             continue
         if re.match('\W*JPY\W*', list[0]) and \
            re.match('現鈔'.decode('utf-8'), list[1]):
             jpy = list[3]
     item['jpy'] = jpy
     yield item
 def parse(self, response):
     print('response:%s' % response)
     item = CurrencyItem(name='Chang Hwa bank', updated_time=datetime.now())
     currency_table = response.xpath(
         '//div[@id="content-inside"]//table[@class="table table-data"]/tbody'
     )
     jpy = ''
     for row in currency_table.xpath('tr'):
         currencies = []
         for col in row.xpath('td'):
             c = col.xpath('normalize-space(text())').extract_first("0")
             currencies.append(c)
         if re.match("\W*JPY-C\W*", currencies[0].encode('UTF-8')):
             jpy = currencies[2]
             item['currency'] = jpy
             item['coin_type'] = 'jpy'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match("\W*THB\W*", currencies[0].encode('UTF-8')):
             thb = currencies[2]
             item['currency'] = thb
             item['coin_type'] = 'thb'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match("\W*EUR-C\W*", currencies[0].encode('UTF-8')):
             eur = currencies[2]
             item['currency'] = eur
             item['coin_type'] = 'eur'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match("\W*USD-C\W*", currencies[0].encode('UTF-8')):
             usd = currencies[2]
             item['currency'] = usd
             item['coin_type'] = 'usd'
             item['flow_type'] = 'cash_selling'
             yield item
예제 #7
0
 def parse(self, response):
     print('china trust:%s' % response)
     item = CurrencyItem(name='ChinaTrust bank',
                         updated_time=datetime.now())
     currency_table = response.xpath('//*[@id="mainTable"]')
     jpy = []
     for row in currency_table.xpath('tr'):
         currencies = [
             col.xpath('normalize-space(text())').extract_first('0')
             for col in row.xpath('td')
         ]
         print currencies[0]
         if re.match('\W*JPY\W*', currencies[0]):
             jpy = currencies[2]
             item['currency'] = jpy
             item['coin_type'] = 'jpy'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*USD\W*', currencies[0]):
             usd = currencies[2]
             item['currency'] = usd
             item['coin_type'] = 'usd'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*THB\W*', currencies[0]):
             thb = currencies[2]
             item['currency'] = thb
             item['coin_type'] = 'thb'
             item['flow_type'] = 'cash_selling'
             yield item
         if re.match('\W*EUR\W*', currencies[0]):
             eur = currencies[2]
             item['currency'] = eur
             item['coin_type'] = 'eur'
             item['flow_type'] = 'cash_selling'
             yield item