import scrapy import sys from scrapy.selector import Selector from scrapy.http import Request from mypjt.items import MypjtItem import time,datetime import pymysql from mypjt.Public_Module import check_all_currency_tb,getGroupData from mypjt.logger import init_logger logger=init_logger(__name__) class EurSpider(scrapy.Spider): name = 'EUR' allowed_domains = ['zou114.com'] start_urls = ['http://www.zou114.com/agiotage/hl2.asp?from=EUR&to=CNY&q=1'] def __init__(self): super(EurSpider,self).__init__() self.currency_name='EUR' self.currency_tb_name=self.currency_name+'_tb' self.page_data=[] self.item=MypjtItem() self.item['currency_name']=self.currency_name self.item['data_list']=[] self.item['top_list']=['货币名称','汇率','更新日期','default'] #print(self.item['new_update_date']) self.exchange_currency_list=['CNY','JPY','GBP','USD','RUB']#人民币 美元 英镑 欧元 卢布 self.index=0 logger.info(self.start_urls[0])
# -*- coding: utf-8 -*- import os import sys #import logging from scrapy.selector import Selector import time, datetime import pymysql import logging from mypjt.logger import LoggerSet, init_logger, logFilePath #from mypjt.settings import LOG_FILE #logfilepathname=init_logFile('logfile') #cmdLogSet=LoggerSet(logging.INFO,'',['[%(asctime)s]-[%(filename)s]-[%(levelname)s]-[%(funcName)s]-[%(lineno)s] : %(message)s', '%Y-%m-%d %H:%M:%S']) #ileLogSet=LoggerSet(logging.INFO,logFilePath,['[%(asctime)s]-[%(filename)s]-[%(levelname)s]-[%(funcName)s]-[%(lineno)d] : %(message)s', '%Y-%m-%d %H:%M:%S']) logger = init_logger(__name__) #,fileLogSet,cmdLogSet # 货币 中英文缩写对照dict currency_translate_dict={'人民币':'CNY','阿联酋迪拉姆':'AED','澳大利亚元':'AUD', \ '巴西里亚尔':'BRL','加拿大元':'CAD','瑞士法郎':'CHF','丹麦克朗':'DKK','欧元':'EUR', \ '英镑':'GBP','港币':'HKD','印尼卢比':'IDR','印度卢比':'INR','日元':'JPY', \ '韩国元':'KRW','澳门元':'MOP','林吉特':'MYR','挪威克朗':'NOK','新西兰元':'NZD', \ '菲律宾比索':'PHP','卢布':'RUB','沙特里亚尔':'SAR','瑞典克朗':'SEK','新加坡元':'SGD', \ '泰国铢':'THB','土耳其里拉':'TRY','新台币':'TWD','美元':'USD','南非兰特':'ZAR' \ } top_dict={'货币名称':'CurrencyName','现汇买入价':'BuyingRate','现钞买入价':'CashBuyingRate', \ '现汇卖出价':'SellingRate','现汇卖出价':'CashSellingRate','中行折算价':'MiddleRate'} def getData_1(response, currency_name): respp = response.xpath(