born 6 роки тому
коміт
abef318909
40 змінених файлів з 1247 додано та 0 видалено
  1. 1 0
      .gitignore
  2. 7 0
      collectSports/__init__.py
  3. BIN
      collectSports/__pycache__/__init__.cpython-37.pyc
  4. BIN
      collectSports/__pycache__/items.cpython-37.pyc
  5. BIN
      collectSports/__pycache__/settings.cpython-37.pyc
  6. 29 0
      collectSports/conf/hg0088.json
  7. 15 0
      collectSports/conf/settings.json
  8. 36 0
      collectSports/items.py
  9. 7 0
      collectSports/mcollect/__init__.py
  10. BIN
      collectSports/mcollect/__pycache__/__init__.cpython-37.pyc
  11. 7 0
      collectSports/mcollect/hg0088/LinkPool.py
  12. 29 0
      collectSports/mcollect/hg0088/Resolver.py
  13. 3 0
      collectSports/mcollect/hg0088/Storage.py
  14. 12 0
      collectSports/mcollect/hg0088/__init__.py
  15. BIN
      collectSports/mcollect/hg0088/__pycache__/Resolver.cpython-37.pyc
  16. BIN
      collectSports/mcollect/hg0088/__pycache__/__init__.cpython-37.pyc
  17. 144 0
      collectSports/mcollect/hg0088/fcache/hg0088.zaopan.js
  18. 60 0
      collectSports/mcollect/hg0088/tmpl/zaopan.tmpl
  19. 0 0
      collectSports/mcollect/hg3535/__init__.py
  20. 103 0
      collectSports/middlewares.py
  21. 11 0
      collectSports/pipelines.py
  22. 0 0
      collectSports/pipelines/__init__.py
  23. BIN
      collectSports/pipelines/__pycache__/__init__.cpython-37.pyc
  24. BIN
      collectSports/pipelines/__pycache__/sportslst.cpython-37.pyc
  25. 13 0
      collectSports/pipelines/sportslst.py
  26. 90 0
      collectSports/settings.py
  27. 5 0
      collectSports/spiders/__init__.py
  28. BIN
      collectSports/spiders/__pycache__/__init__.cpython-37.pyc
  29. BIN
      collectSports/spiders/__pycache__/sports.cpython-37.pyc
  30. BIN
      collectSports/spiders/__pycache__/sportslst.cpython-37.pyc
  31. 42 0
      collectSports/spiders/sports.py
  32. 88 0
      collectSports/spiders/sportslst.py
  33. 1 0
      pycomm/.gitignore
  34. 2 0
      pycomm/README.md
  35. 298 0
      pycomm/__init__.py
  36. 81 0
      pycomm/db.py
  37. 51 0
      pycomm/mongo.py
  38. 43 0
      pycomm/redisop.py
  39. 58 0
      pycomm/sqlite.py
  40. 11 0
      scrapy.cfg

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/log

+ 7 - 0
collectSports/__init__.py

@@ -0,0 +1,7 @@
+import sys,os
+ROOT_PATH=os.path.dirname(os.path.abspath(__file__))
+sys.path.append(ROOT_PATH+'../pycomm/')
+sys.path.append(ROOT_PATH)
+import pycomm
+sysSettings=pycomm.ldjson(ROOT_PATH+'/conf/settings.json')
+pycomm.setCache('conf',sysSettings)

BIN
collectSports/__pycache__/__init__.cpython-37.pyc


BIN
collectSports/__pycache__/items.cpython-37.pyc


BIN
collectSports/__pycache__/settings.cpython-37.pyc


+ 29 - 0
collectSports/conf/hg0088.json

@@ -0,0 +1,29 @@
+{
+    "root":[
+        {
+            "plodds":"temaball",
+            "prodds":"sw_OUH",
+            "enabled":0,
+            "items":[
+                {
+                    "lodds":"",
+                    "rodds":"",
+                    "ratio":"0",
+                    "ratio_name":"ratio",
+                    "oddsv":"",
+                    "handle":"",
+                    "uid":""
+                },
+                {
+                    "lodds":"",
+                    "rodds":"ior_OUH",
+                    "ratio":"2.5",
+                    "ratio_name":"ratio_o",
+                    "oddsv":"",
+                    "handle":"",
+                    "uid":""
+                }
+            ]
+        }
+    ]
+}

+ 15 - 0
collectSports/conf/settings.json

@@ -0,0 +1,15 @@
+{
+    "currentSource":"hg0088",
+    "redis":{
+        "host":"",
+        "port":"",
+        "password":""
+    },
+    "mongo":{
+        "host":"localhost",
+        "port":"27017",
+        "user":"sports",
+        "password":"123456",
+        "dbname":"sports"
+    }
+}

+ 36 - 0
collectSports/items.py

@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Define here the models for your scraped items
+#
+# See documentation in:
+# https://doc.scrapy.org/en/latest/topics/items.html
+
+import scrapy
+
+
+class CollectsportsItem(scrapy.Item):
+    # define the fields for your item here like:
+    zq_league = scrapy.Field()
+    zq_match = scrapy.Field()
+    
+
+class ZqLeagueItem(scrapy.Item):
+    league_id=scrapy.Field()
+    league_name=scrapy.Field()
+    
+class ZqMatch(scrapy.Item):
+    match_id=scrapy.Field()
+    match_name=scrapy.Field()
+    host_id=scrapy.Field()
+    guest_id=scrapy.Field()
+    is_half=scrapy.Field() #是否上半场
+    half_match_id=scrapy.Field()
+    odds_num=scrapy.Field() #总玩法数量
+    host_name=scrapy.Field()
+    is_roll=scrapy.Field() #滚球
+    mdate=scrapy.Field() #日期
+    mtime=scrapy.Field()#时间
+    is_corner=scrapy.Field()#是否角球
+    guest_name=scrapy.Field()
+    league_id=scrapy.Field()
+    

+ 7 - 0
collectSports/mcollect/__init__.py

@@ -0,0 +1,7 @@
+import pycomm
+from pycomm import mongo
+
+def getMongo():
+    conf=pycomm.getCache('conf')
+    mongoConf=conf['mongo']
+    return mongo.DBMongo(mongoConf['host'],mongoConf['dbname'],mongoConf['user'],mongoConf['password'],mongoConf['port'])

BIN
collectSports/mcollect/__pycache__/__init__.cpython-37.pyc


+ 7 - 0
collectSports/mcollect/hg0088/LinkPool.py

@@ -0,0 +1,7 @@
+class LinkPool(object):
+    links=[]
+    def __init__(self):
+        self.links.append({'url':"http://199.26.100.178/app/member/live/game_list.php?uid=yznixox4m21627573l305947&langx=zh-cn&gtype=All&gdate=All",'cb':''})
+        pass
+    def getLinks(self):
+        return self.links

+ 29 - 0
collectSports/mcollect/hg0088/Resolver.py

@@ -0,0 +1,29 @@
+
+import pycomm,os,lxml
+import mcollect
+class Resolver(object):
+    def __init__(self):
+        pass
+    def zaopan(self,data):    
+        print(mcollect.getMongo())
+        re=self.mixbodyv(data,'zaopan')
+        return re
+
+    def today(self,data):
+        re=self.mixbodyv(data,'today')
+        return re
+
+    def mixbodyv(self,data,fname):
+        cpath=os.path.dirname(os.path.abspath(__file__))   
+        val=pycomm.readFile(cpath+'/tmpl/zaopan.tmpl')
+        data=str(data.decode('utf-8'))
+
+        doc = lxml.etree.HTML(data)
+        # doc=lxml.etree.fromstring(data)  
+        ls=doc.xpath('/html/head/script[2]/text()')
+        text=ls[0]      
+        ftext=pycomm.parseTag(val,'CONTENT',text)
+        ftext=str(ftext.encode('utf-8').decode('utf-8'))
+        pycomm.saveFile(cpath+'/fcache/hg0088.'+fname+'.js',ftext)
+        re=pycomm.exejs('node '+cpath+'/fcache/hg0088.'+fname+'.js')
+        return re

+ 3 - 0
collectSports/mcollect/hg0088/Storage.py

@@ -0,0 +1,3 @@
+class Storage(object):
+    def __init__(self):
+        pass

+ 12 - 0
collectSports/mcollect/hg0088/__init__.py

@@ -0,0 +1,12 @@
+
+links=[]
+uid="pnu23pc6ym21680472l75456"
+
+# links.append({'url':'http://baidu.com','cb':'zaopan'})
+
+# # 所有后期联赛
+# links.append({'url':"http://199.26.100.178/app/member/live/game_list.php?uid={uid}&langx=zh-cn&gtype=All&gdate=All",'cb':'zhibo'})
+# # 冠军杯
+# links.append({'url':"http://199.26.100.178/app/member/browse_FS/reloadgame_R.php?mid=21627573&uid={uid}&langx=zh-cn&choice=ALL&LegGame=ALL&pages=1&records=40&FStype=FT&area_id=&league_id=&rtype=fs&hot_game=",'cb':'chain'})
+# # 早盘
+links.append({'url':"https://199.26.100.178/app/member/FT_future/body_var.php?uid={uid}&rtype=r&langx=zh-cn&mtype=4&page_no={page}&league_id=&hot_game=&g_date=ALL&isie11=%27N%27",'cb':'zaopan'})

BIN
collectSports/mcollect/hg0088/__pycache__/Resolver.cpython-37.pyc


BIN
collectSports/mcollect/hg0088/__pycache__/__init__.cpython-37.pyc


+ 144 - 0
collectSports/mcollect/hg0088/fcache/hg0088.zaopan.js

@@ -0,0 +1,144 @@
+
+var parent={};
+var top={};
+
+function checkCorner(item){
+	if(item.split('角球数')>1){
+		return 1;
+	}
+	return 0;
+}
+parent.body_var_onLoad=function(){
+	this.data={};
+	this.data.total_page=this.t_page;
+	this.data.retime=this.retime;
+
+	this.result=[];
+	
+	for(let index in G)
+	{
+		var item=this.GameFT[index];
+		var col_length=item.length;
+		var tmp={};
+		var date=new Date;
+		tmp.match_id=item[0];
+		var tit=item[1];
+		tit=tit.split('<br>');
+		var year=date.getFullYear();
+		tmp.is_roll=0;
+		if(tit.length>2){
+			tmp.is_roll=1;
+		}		
+		tmp.mdate=year+'-'+tit[0];
+		
+		tmp.mtime=tit[1];
+		tmp.half_match_id=item[22];
+		tmp.league_name=item[2];
+		tmp.host_id=item[3];
+		tmp.guest_id=item[4];
+		tmp.host_name=item[5];
+		tmp.guest_name=item[6];
+		tmp.league_id=item[39];
+		tmp.odds_num=item[34];
+		tmp.hot=item[36];
+		tmp.play=item[38];
+		tmp.special=item[45];
+		tmp.ptype=item[44];//联赛附属类型,比如,会晋级,角球数
+		tmp.is_corner=checkCorner(tmp.ptype);
+
+
+		this.result.push(tmp);
+	}
+	this.data.data=this.result;
+	console.log(JSON.stringify(this.data));
+}
+
+
+
+
+_=parent;
+_.flash_ior_set='Y';
+_.rtype='r';
+_.sel_lid='';
+top.today_gmt = '2019-05-29';
+top.now_gmt = '02:54:42';
+G=_.GameFT=[];
+g=function(_){G.push(_);}
+top.SortType='';
+top.pageType='def';
+top.filterType='XX';
+_.isObt='';
+_.g_date = 'ALL';
+_.clean_data_sw='N';
+_.GameHead = ['gid','datetime','league','gnum_h','gnum_c','team_h','team_c','strong','ratio','ior_RH','ior_RC','ratio_o','ratio_u','ior_OUH','ior_OUC','ior_MH','ior_MC','ior_MN','str_odd','str_even','ior_EOO','ior_EOE','hgid','hstrong','hratio','ior_HRH','ior_HRC','hratio_o','hratio_u','ior_HOUH','ior_HOUC','ior_HMH','ior_HMC','ior_HMN','more','eventid','hot','center_tv','play','gidm','isMaster','hide_N','obt_type','ptype_map','ptype','important'];
+_.retime=180;
+_.game_more=1;
+_.t_page=4;
+_.gamount=60;
+g(['3705896','05-30<br>08:00a<br><font color=red>Running Ball</font>','芬兰甲组联赛','40498','40497','埃克纳斯','卡亚尼','H','0 / 0.5','0.920','0.980','O2.5 / 3','U2.5 / 3','1.040','0.840','2.21','2.80','3.70','单','双','1.95','1.94','3705897','H','0','0.690','1.210','O1 / 1.5','U1 / 1.5','0.760','1.120','2.68','3.45','2.29','66','','','','N','2594806','Y','N','0','0','','N']);
+g(['3705898','05-30<br>08:00a<br><font color=red>Running Ball</font>','芬兰甲组联赛','40500','40499','埃克纳斯','卡亚尼','H','0.5','1.190','0.710','O3','U3','0.760','1.120','','','','','','','','3705899','H','0 / 0.5','1.240','0.660','O1','U1','1.220','0.660','','','','0','','','','N','2594806','N','N','0','0','','N']);
+g(['3705900','05-30<br>08:00a<br><font color=red>Running Ball</font>','芬兰甲组联赛','40506','40505','查路','TPV谭柏利','H','1 / 1.5','1.070','0.830','O2.5','U2.5','1.020','0.860','1.43','6.30','4.45','单','双','1.95','1.94','3705901','H','0.5','1.050','0.850','O1','U1','1.050','0.830','2.04','5.90','2.26','66','','','','N','2594810','Y','N','0','0','','N']);
+g(['3705902','05-30<br>08:00a<br><font color=red>Running Ball</font>','芬兰甲组联赛','40508','40507','查路','TPV谭柏利','H','1','0.760','1.140','O2.5 / 3','U2.5 / 3','0.770','1.110','','','','','','','','3705903','H','0 / 0.5','0.670','1.230','O1 / 1.5','U1 / 1.5','0.620','1.260','','','','0','','','','N','2594810','N','N','0','0','','N']);
+g(['3704524','05-30<br>08:00a<br><font color=red>Running Ball</font>','瑞典南部甲组联赛','40268','40267','特瓦克斯','史柯瓦德','H','0','0.760','1.020','O2.5','U2.5','0.810','0.970','2.29','2.64','3.30','单','双','1.96','1.93','3704525','H','0','0.780','1.000','O1','U1','0.870','0.910','2.95','3.30','2.10','11','','','','N','2592005','Y','N','0','0','','N']);
+g(['3704408','05-30<br>09:00a<br><font color=red>Running Ball</font>','瑞典杯','40002','40001','赫根','AFC埃斯基尔斯蒂纳','H','1.5','0.890','1.010','O2.5 / 3','U2.5 / 3','0.890','0.990','1.25','10.50','5.40','单','双','1.95','1.94','3704409','H','0.5 / 1','1.090','0.810','O1','U1','1.120','0.760','1.75','8.30','2.43','70','','','','N','2582725','Y','N','0','0','','N']);
+g(['3704410','05-30<br>09:00a<br><font color=red>Running Ball</font>','瑞典杯','40004','40003','赫根','AFC埃斯基尔斯蒂纳','H','1.5 / 2','1.120','0.780','O2.5','U2.5','1.150','0.730','','','','','','','','3704411','H','0.5','0.760','1.140','O1 / 1.5','U1 / 1.5','0.710','1.170','','','','0','','','','N','2582725','N','N','0','0','','N']);
+g(['3704500','05-30<br>09:00a<br><font color=red>Running Ball</font>','瑞典北部甲组联赛','40232','40231','加费莱','托尔恩格鲁本','H','0 / 0.5','0.950','0.830','O2.5','U2.5','0.830','0.950','2.17','2.84','3.25','单','双','1.96','1.93','3704501','H','0','0.710','1.070','O1','U1','0.850','0.930','2.80','3.40','2.13','11','','','','N','2591951','Y','N','0','0','','N']);
+g(['3704504','05-30<br>09:00a','瑞典北部甲组联赛','40238','40237','霖高平城','维萨隆德','H','0.5','0.830','0.950','O3','U3','0.810','0.970','1.82','3.35','3.70','单','双','1.95','1.94','3704505','H','0 / 0.5','0.960','0.820','O1 / 1.5','U1 / 1.5','0.800','0.980','2.32','3.80','2.35','11','','','','N','2591954','Y','N','0','0','','N']);
+g(['3704528','05-30<br>09:00a<br><font color=red>Running Ball</font>','瑞典南部甲组联赛','40274','40273','艾斯基斯迈','欧卡莎姆','C','0 / 0.5','0.760','1.020','O3','U3','0.790','0.990','2.55','2.22','3.60','单','双','1.95','1.94','3704529','C','0','0.990','0.790','O1 / 1.5','U1 / 1.5','0.790','0.990','3.05','2.77','2.31','11','','','','N','2592008','Y','N','0','0','','N']);
+g(['3715832','05-30<br>10:00a<br><font color=red>Running Ball</font>','丹麦甲组联赛-附加赛','41454','41453','宁比','文德斯尔','H','0','0.860','1.040','O2 / 2.5','U2 / 2.5','0.800','1.080','2.60','2.87','3.15','单','双','1.97','1.92','3715833','H','0','0.890','1.010','O0.5 / 1','U0.5 / 1','1.090','0.790','3.30','3.60','1.92','70','','','','N','2605014','Y','N','0','0','','N']);
+g(['3715834','05-30<br>10:00a<br><font color=red>Running Ball</font>','丹麦甲组联赛-附加赛','41456','41455','宁比','文德斯尔','H','0 / 0.5','1.190','0.710','O2','U2','1.120','0.760','','','','','','','','3715835','H','0 / 0.5','1.390','0.510','O1','U1','0.630','1.250','','','','0','','','','N','2605014','N','N','0','0','','N']);
+g(['3704512','05-30<br>10:00a<br><font color=red>Running Ball</font>','瑞典北部甲组联赛','40250','40249','尼科平斯','卡尔斯塔德','H','0','0.820','0.960','O2.5','U2.5','0.840','0.940','2.36','2.53','3.35','单','双','1.96','1.93','3704513','H','0','0.840','0.940','O1','U1','0.900','0.880','3.00','3.15','2.12','11','','','','N','2591960','Y','N','0','0','','N']);
+g(['3704516','05-30<br>10:00a<br><font color=red>Running Ball</font>','瑞典北部甲组联赛','40256','40255','希薇亚','桑德维肯斯','C','0 / 0.5','0.860','0.920','O3','U3','0.760','0.860','2.69','2.11','3.65','单','双','1.95','1.94','3704517','C','0','1.070','0.710','O1 / 1.5','U1 / 1.5','0.820','0.960','3.20','2.64','2.33','11','','','','N','2591963','Y','N','0','0','','N']);
+g(['3704532','05-30<br>10:00a<br><font color=red>Running Ball</font>','瑞典南部甲组联赛','40280','40279','隆德','艾维达堡','H','0.5','0.880','0.900','O2.5 / 3','U2.5 / 3','0.860','0.920','1.87','3.40','3.40','单','双','1.95','1.94','3704533','H','0 / 0.5','1.010','0.770','O1 / 1.5','U1 / 1.5','0.690','1.090','2.41','3.80','2.25','11','','','','N','2592011','Y','N','0','0','','N']);
+g(['3704536','05-30<br>10:00a<br><font color=red>Running Ball</font>','瑞典南部甲组联赛','40286','40285','兰斯干拿','阿西里斯卡图拉丁','H','1','0.920','0.860','O2.5','U2.5','0.990','0.790','1.50','5.00','3.95','单','双','1.95','1.94','3704537','H','0 / 0.5','0.710','1.070','O1','U1','1.040','0.740','2.07','5.10','2.27','11','','','','N','2592014','Y','N','0','0','','N']);
+g(['3704520','05-30<br>11:00a<br><font color=red>Running Ball</font>','瑞典北部甲组联赛','40262','40261','卡斯隆德HFK','乌米亚','C','0.5','0.860','0.920','O2.5','U2.5','0.840','0.940','3.35','1.90','3.40','单','双','1.96','1.93','3704521','C','0 / 0.5','0.740','1.040','O1','U1','0.900','0.880','3.95','2.50','2.14','11','','','','N','2591966','Y','N','0','0','','N']);
+g(['3704540','05-30<br>11:00a<br><font color=red>Running Ball</font>','瑞典南部甲组联赛','40292','40291','奥迪沃德','克里斯提斯塔','H','1','0.970','0.810','O3','U3','0.790','0.990','1.54','4.45','4.05','单','双','1.95','1.94','3704541','H','0 / 0.5','0.740','1.040','O1 / 1.5','U1 / 1.5','0.790','0.990','2.08','4.60','2.37','11','','','','N','2592017','Y','N','0','0','','N']);
+g(['3715840','05-30<br>12:00p<br><font color=red>Running Ball</font>','丹麦甲组联赛-附加赛','41488','41487','霍布罗','域堡','H','0 / 0.5','1.010','0.890','O2 / 2.5','U2 / 2.5','0.830','1.050','2.33','3.20','3.20','单','双','1.97','1.92','3715841','H','0','0.690','1.210','O0.5 / 1','U0.5 / 1','1.110','0.770','2.90','3.90','2.01','70','','','','N','2605031','Y','N','0','0','','N']);
+g(['3715842','05-30<br>12:00p<br><font color=red>Running Ball</font>','丹麦甲组联赛-附加赛','41490','41489','霍布罗','域堡','H','0.5','1.260','0.640','O2','U2','1.150','0.730','','','','','','','','3715843','H','0 / 0.5','1.330','0.570','O1','U1','0.630','1.250','','','','0','','','','N','2605031','N','N','0','0','','N']);
+g(['3705968','05-30<br>12:00p<br><font color=red>Running Ball</font>','U20世界杯2019(在波兰)','40514','40513','纽西兰 U20','乌拉圭U20','C','0.5','0.730','1.110','O2.5 / 3','U2.5 / 3','0.770','1.050','2.85','2.11','3.40','单','双','1.95','1.94','3705969','C','0 / 0.5','0.750','1.090','O1','U1','1.030','0.790','3.75','2.51','2.19','62','','','','N','2595086','Y','N','0','0','','N']);
+g(['3705972','05-30<br>12:00p<br><font color=red>Running Ball</font>','U20世界杯2019(在波兰)','40548','40547','挪威U20','洪都拉斯U20','H','1 / 1.5','0.960','0.880','O3','U3','0.950','0.870','1.40','5.50','4.50','单','双','1.95','1.94','3705973','H','0.5','0.920','0.920','O1 / 1.5','U1 / 1.5','0.880','0.940','1.91','5.40','2.44','62','','','','N','2595103','Y','N','0','0','','N']);
+g(['3710992','05-30<br>02:00p<br><font color=red>Running Ball</font>','国际友谊赛','40692','40691','土耳其','希腊','H','0.5','0.760','1.140','O2','U2','1.040','0.840','1.75','5.20','3.45','单','双','1.97','1.92','3710993','H','0 / 0.5','0.970','0.930','O0.5 / 1','U0.5 / 1','1.070','0.810','2.47','5.40','1.96','66','','','','N','2599695','Y','N','0','0','','N']);
+g(['3705976','05-30<br>02:30p<br><font color=red>Running Ball</font>','U20世界杯2019(在波兰)','40582','40581','尼日利亚 U20','乌克兰U20','H','0 / 0.5','1.130','0.710','O2.5','U2.5','0.860','0.960','2.38','2.60','3.15','单','双','1.96','1.93','3705977','H','0','0.860','0.980','O1','U1','0.920','0.900','3.00','3.15','2.13','62','','','','N','2595120','Y','N','0','0','','N']);
+g(['3705980','05-30<br>02:30p<br><font color=red>Running Ball</font>','U20世界杯2019(在波兰)','40616','40615','美国U20','卡塔尔U20','H','1.5 / 2','0.800','1.040','O3','U3','0.810','1.010','1.17','11.00','5.80','单','双','1.95','1.94','3705981','H','0.5 / 1','0.810','1.030','O1 / 1.5','U1 / 1.5','0.810','1.010','1.58','9.00','2.65','62','','','','N','2595137','Y','N','0','0','','N']);
+g(['3711660','05-30<br>02:45p<br><font color=red>Running Ball</font>','法国乙组联赛-附加赛','40748','40747','朗斯','第戎','H','0 / 0.5','0.970','0.930','O2','U2','1.050','0.830','2.26','2.99','3.10','单','双','1.97','1.92','3711661','H','0','0.710','1.190','O0.5 / 1','U0.5 / 1','1.080','0.800','2.96','3.75','1.93','66','8BBCB7CCB7CCBABCBEBCB6CCB9BCB38DC9C6CFCFC9CDCBA9B3','','p双rf单rm','N','2600962','Y','N','0','0','','N']);
+g(['3711662','05-30<br>02:45p<br><font color=red>Running Ball</font>','法国乙组联赛-附加赛','40750','40749','朗斯','第戎','H','0.5','1.220','0.680','O2 / 2.5','U2 / 2.5','0.760','1.120','','','','','','','','3711663','H','0 / 0.5','1.290','0.610','O1','U1','0.630','1.250','','','','0','','','','N','2600962','N','N','0','0','','N']);
+g(['3715802','05-30<br>02:45p<br><font color=red>Running Ball</font>','土耳其甲组联赛-附加赛','41432','41431','哈塔斯堡 [中]','加斯希尔加斯安泰普','H','0','0.740','1.120','O2 / 2.5','U2 / 2.5','0.810','1.030','2.27','2.78','3.10','单','双','1.96','1.93','3715803','H','0','0.760','1.100','O0.5 / 1','U0.5 / 1','1.110','0.730','3.00','3.55','1.98','11','','','','N','2604954','Y','N','0','0','','N']);
+g(['3715766','05-30<br>03:00p<br><font color=red>Running Ball</font>','意大利乙组联赛-附加赛','41352','41351','奇塔代拉','维罗纳','H','0 / 0.5','0.900','1.000','O2 / 2.5','U2 / 2.5','0.870','1.010','2.23','3.50','3.15','单','双','1.98','1.91','3715767','H','0','0.670','1.230','O0.5 / 1','U0.5 / 1','1.100','0.780','3.05','4.15','1.88','70','86CCBBBCBCBCBABCBEBCB6CCBABCB387CDC7CBCFC9CDCBA9B3','','p双rf单rm','N','2604828','Y','N','0','0','','N']);
+g(['3715768','05-30<br>03:00p<br><font color=red>Running Ball</font>','意大利乙组联赛-附加赛','41354','41353','奇塔代拉','维罗纳','H','0.5','1.200','0.700','O2','U2','1.170','0.710','','','','','','','','3715769','H','0 / 0.5','1.270','0.630','O1','U1','0.660','1.220','','','','0','','','','N','2604828','N','N','0','0','','N']);
+g(['3704544','05-30<br>04:00p<br><font color=red>Running Ball</font>','南美洲球会杯','40298','40297','拉罗竞技','哥连泰斯SP','C','0 / 0.5','0.920','0.920','O2','U2','0.860','0.960','3.10','2.17','2.98','单','双','1.97','1.92','3704545','C','0','1.150','0.690','O0.5 / 1','U0.5 / 1','0.910','0.910','3.85','2.98','1.91','11','8BBCBBBCBEBCBABCBEBCBEBCB9CCB38DCEC8CDC6CACDCBA9B3','','p双rf单rm','N','2592712','Y','N','0','0','','N']);
+g(['3704548','05-30<br>06:15p<br><font color=red>Running Ball</font>','南美洲球会杯','40326','40325','切洛','万特雷斯','C','0','1.080','0.760','O2','U2','0.760','1.060','2.81','2.38','2.91','单','双','1.98','1.91','3704549','C','0','1.070','0.770','O0.5 / 1','U0.5 / 1','0.860','0.960','3.70','3.20','1.86','11','8BBCBCBCBABCBABCBEBCBEBCB9CCB389CDC8CDC6CACDCBA9B3','','p双rf单rm','N','2592726','Y','N','0','0','','N']);
+g(['3704552','05-30<br>06:15p<br><font color=red>Running Ball</font>','南美洲球会杯','40354','40353','托利马','小阿根廷人','H','0.5','0.760','1.080','O2','U2','0.790','1.030','1.75','4.50','3.05','单','双','1.98','1.91','3704553','H','0 / 0.5','1.010','0.830','O0.5 / 1','U0.5 / 1','0.860','0.960','2.43','5.40','1.91','11','8BBCB6CCBCBCBABCBEBCB6CCB9BCB38FCBC8CDC6CACDCBA9B3','','p双rf单rm','N','2592740','Y','N','0','0','','N']);
+g(['3704436','05-30<br>07:00p<br><font color=red>Running Ball</font>','巴西杯','40110','40109','彭美拉斯SP','森柏欧MA','H','2','0.730','1.170','O3','U3','0.910','0.970','1.11','18.50','7.80','单','双','1.95','1.94','3704437','H','0.5 / 1','0.710','1.190','O1 / 1.5','U1 / 1.5','0.870','1.010','1.52','11.50','2.67','62','','','','N','2590281','Y','N','0','0','','N']);
+g(['3704556','05-30<br>08:30p<br><font color=red>Running Ball</font>','南美洲球会杯','40382','40381','卡托利卡','瓦伦独立','H','1','0.810','1.030','O2.5 / 3','U2.5 / 3','0.860','0.960','1.44','5.40','4.15','单','双','1.95','1.94','3704557','H','0.5','1.060','0.780','O1','U1','1.060','0.760','2.05','5.10','2.28','11','8BBCB6CCBEBCBABCBEBCB6CCB9BCB38BCAC8CDC6CACDCBA9B3','','p双rf单rm','N','2592754','Y','N','0','0','','N']);
+g(['3704426','05-30<br>08:30p<br><font color=red>Running Ball</font>','南美超级杯','40082','40081','河床','帕拉尼恩斯','H','0.5 / 1','0.830','1.070','O2','U2','1.070','0.810','1.62','5.50','3.55','单','双','1.97','1.92','3704427','H','0 / 0.5','0.890','1.010','O0.5 / 1','U0.5 / 1','1.090','0.790','2.31','5.70','2.02','66','8BBCB9CCBCBCBABCBEBCB6CCB9BCB387C9CDC7C7CACDCBA9B3','','p双rf单rm','N','2588268','Y','N','0','0','','N']);
+g(['3704428','05-30<br>08:30p<br><font color=red>Running Ball</font>','南美超级杯','40084','40083','河床','帕拉尼恩斯','H','1','1.170','0.730','O2 / 2.5','U2 / 2.5','0.790','1.090','','','','','','','','3704429','H','0.5','1.250','0.650','O1','U1','0.640','1.240','','','','0','','','','N','2588268','N','N','0','0','','N']);
+g(['3708062','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50092','50091','路云尼米','赫尔辛基','C','0.5 / 1','0.820','1.080','O2 / 2.5','U2 / 2.5','0.820','1.060','5.10','1.78','3.40','单','双','1.98','1.91','3708063','C','0 / 0.5','0.860','1.040','O0.5 / 1','U0.5 / 1','1.120','0.760','4.95','2.56','1.97','70','89CCB9CCB9CCBABCBEBCB6CCBDBCB389CAC8CBC6CACDCBA9B3','','p双rf单rm','N','2594756','Y','N','0','0','','N']);
+g(['3708064','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50094','50093','路云尼米','赫尔辛基','C','0.5','1.110','0.790','O2','U2','1.120','0.760','','','','','','','','3708065','C','0.5','0.530','1.370','O1','U1','0.650','1.230','','','','0','','','','N','2594756','N','N','0','0','','N']);
+g(['3708072','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50104','50103','HIFK赫尔辛基','VPS华沙','H','0 / 0.5','0.970','0.930','O2','U2','0.850','1.030','2.26','3.60','3.05','单','双','1.98','1.91','3708073','H','0','0.690','1.210','O0.5 / 1','U0.5 / 1','0.950','0.930','3.15','4.15','1.85','70','89CCB9CCBEBCBABCBEBCB6CCBDBCB38DC9C8CBC6CACDCBA9B3','','p双rf单rm','N','2594762','Y','N','0','0','','N']);
+g(['3708074','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50106','50105','HIFK赫尔辛基','VPS华沙','H','0.5','1.220','0.680','O1.5 / 2','U1.5 / 2','1.140','0.740','','','','','','','','3708075','H','0 / 0.5','1.320','0.580','O0.5','U0.5','1.300','0.580','','','','0','','','','N','2594762','N','N','0','0','','N']);
+g(['3708082','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50116','50115','英特杜古','伊尔韦斯','H','0 / 0.5','0.970','0.930','O2','U2','1.050','0.830','2.28','3.35','3.20','单','双','1.97','1.92','3708083','H','0','0.710','1.190','O0.5 / 1','U0.5 / 1','1.120','0.760','2.98','3.85','1.98','70','89CCB9CCB7CCBABCBEBCB6CCBDBCB387C9C8CBC6CACDCBA9B3','','p双rf单rm','N','2594768','Y','N','0','0','','N']);
+g(['3708084','05-31<br>11:30a<br><font color=red>Running Ball</font>','芬兰超级联赛','50118','50117','英特杜古','伊尔韦斯','H','0.5','1.230','0.670','O2 / 2.5','U2 / 2.5','0.750','1.130','','','','','','','','3708085','H','0 / 0.5','1.310','0.590','O1','U1','0.660','1.220','','','','0','','','','N','2594768','N','N','0','0','','N']);
+g(['3715822','05-31<br>01:00p<br><font color=red>Running Ball</font>','丹麦超级联赛-附加赛','51448','51447','布隆德比','兰讷斯','H','0.5','0.840','1.060','O2.5 / 3','U2.5 / 3','0.860','1.020','1.83','4.15','3.80','单','双','1.96','1.93','3715823','H','0 / 0.5','1.000','0.900','O1','U1','1.080','0.800','2.42','4.30','2.20','70','','','','N','2604993','Y','N','0','0','','N']);
+g(['3715824','05-31<br>01:00p<br><font color=red>Running Ball</font>','丹麦超级联赛-附加赛','51450','51449','布隆德比','兰讷斯','H','0.5 / 1','1.080','0.820','O2.5','U2.5','1.070','0.810','','','','','','','','3715825','H','0.5','1.310','0.590','O1 / 1.5','U1 / 1.5','0.690','1.190','','','','0','','','','N','2604993','N','N','0','0','','N']);
+g(['3708030','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50030','50029','布咸美恩斯','费恩夏普','H','1','0.820','1.080','O2.5','U2.5','0.950','0.930','1.48','6.00','4.20','单','双','1.95','1.94','3708031','H','0.5','1.050','0.850','O1','U1','0.980','0.900','2.04','5.90','2.26','66','','','','N','2594725','Y','N','0','0','','N']);
+g(['3708032','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50032','50031','布咸美恩斯','费恩夏普','H','1 / 1.5','1.140','0.760','O2.5 / 3','U2.5 / 3','0.730','1.150','','','','','','','','3708033','H','0 / 0.5','0.650','1.250','O1 / 1.5','U1 / 1.5','0.580','1.300','','','','0','','','','N','2594725','N','N','0','0','','N']);
+g(['3708042','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50054','50053','登克尔克','斯莱戈流浪','H','1.5 / 2','1.020','0.880','O2.5 / 3','U2.5 / 3','0.910','0.970','1.23','11.00','5.60','单','双','1.95','1.94','3708043','H','0.5 / 1','1.030','0.870','O1 / 1.5','U1 / 1.5','0.750','1.130','1.70','8.50','2.52','66','','','','N','2594737','Y','N','0','0','','N']);
+g(['3708044','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50056','50055','登克尔克','斯莱戈流浪','H','1.5','0.790','1.110','O2.5','U2.5','1.150','0.730','','','','','','','','3708045','H','0.5','0.710','1.190','O1','U1','1.200','0.680','','','','0','','','','N','2594737','N','N','0','0','','N']);
+g(['3708048','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50066','50065','圣帕特里克','科克城','H','0 / 0.5','0.890','1.010','O2 / 2.5','U2 / 2.5','0.790','1.090','2.19','3.20','3.20','单','双','1.97','1.92','3708049','H','0 / 0.5','1.260','0.640','O0.5 / 1','U0.5 / 1','1.100','0.780','2.87','4.05','1.98','66','','','','N','2594743','Y','N','0','0','','N']);
+g(['3708050','05-31<br>02:45p<br><font color=red>Running Ball</font>','爱尔兰超级联赛','50068','50067','圣帕特里克','科克城','H','0.5','1.170','0.730','O2','U2','1.130','0.750','','','','','','','','3708051','H','0','0.640','1.260','O1','U1','0.660','1.220','','','','0','','','','N','2594743','N','N','0','0','','N']);
+g(['3708114','05-31<br>03:00p<br><font color=red>Running Ball</font>','西班牙乙组联赛','50266','50265','科尔多瓦','奥萨苏纳','C','0 / 0.5','0.980','0.860','O2.5','U2.5','0.960','0.860','2.99','2.09','3.25','单','双','1.99','1.9','3708115','C','0','1.180','0.660','O1','U1','0.910','0.910','3.70','2.76','2.06','62','8DBCBEBCBCBCBABCBEBCB6CCBBBCB386CDC9C9C6CACDCBA9B3','','p双rf单rm','N','2596629','Y','N','0','0','','N']);
+g(['3708020','05-31<br>10:00p<br><font color=red>Running Ball</font>','美国职业大联盟','50018','50017','温哥华白帽','多伦多','H','0 / 0.5','1.050','0.850','O2.5 / 3','U2.5 / 3','1.020','0.860','2.31','2.91','3.65','单','双','1.95','1.94','3708021','H','0','0.770','1.130','O1 / 1.5','U1 / 1.5','0.780','1.100','2.81','3.45','2.20','70','8DBCBDBCB6CCBABCB9BCBDBCB38FCECECDC6CACDCBA9B3','','img','N','2592110','Y','N','0','0','','N']);
+g(['3708022','05-31<br>10:00p<br><font color=red>Running Ball</font>','美国职业大联盟','50020','50019','温哥华白帽','多伦多','H','0','0.740','1.160','O3','U3','0.770','1.110','','','','','','','','3708023','H','0 / 0.5','1.250','0.650','O1','U1','1.220','0.660','','','','0','','','','N','2592110','N','N','0','0','','N']);
+g(['3705306','06-01<br>03:30a<br><font color=red>Running Ball</font>','中国超级联赛','60462','60461','北京人和','天津天海','H','0 / 0.5','0.950','0.890','O2.5 / 3','U2.5 / 3','0.610','1.210','2.17','2.82','3.30','单','双','1.96','1.93','3705307','H','0 / 0.5','1.150','0.690','O1','U1','0.930','0.890','2.62','3.55','2.19','58','89BCB9BCB9CCBABCB9BCB8CCB386CECDCBC6CACDCBA9B3','','img','N','2594219','Y','N','0','0','','N']);
+g(['3705316','06-01<br>07:35a<br><font color=red>Running Ball</font>','中国超级联赛','60474','60473','广州富力','河北华夏幸福','H','0.5','0.900','0.940','O2.5 / 3','U2.5 / 3','1.100','0.720','1.89','3.15','3.60','单','双','1.95','1.94','3705317','H','0 / 0.5','1.040','0.800','O1 / 1.5','U1 / 1.5','0.870','0.950','2.43','3.65','2.30','58','89BCBABCB9BCBABCB9BCB8CCB38ACDCDCBC6CACDCBA9B3','','img','N','2594225','Y','N','0','0','','N']);
+g(['3705326','06-01<br>07:35a<br><font color=red>Running Ball</font>','中国超级联赛','60486','60485','山东鲁能泰山','江苏苏宁','H','0.5','0.840','1.000','O2.5 / 3','U2.5 / 3','1.010','0.810','1.80','3.50','3.60','单','双','1.95','1.94','3705327','H','0 / 0.5','1.000','0.840','O1 / 1.5','U1 / 1.5','0.770','1.050','2.36','3.85','2.29','58','89BCBABCBABCBABCB9BCB8CCB38ECCCDCBC6CACDCBA9B3','','img','N','2594231','Y','N','0','0','','N']);
+g(['3705336','06-01<br>07:35a<br><font color=red>Running Ball</font>','中国超级联赛','60498','60497','武汉卓尔','深圳佳兆业','H','0.5','0.830','1.010','O2.5','U2.5','0.930','0.890','1.82','3.60','3.45','单','双','1.95','1.94','3705337','H','0 / 0.5','1.010','0.830','O1','U1','0.970','0.850','2.40','4.15','2.17','58','89BCBABCBCBCBABCB9BCB8CCB388CCCDCBC6CACDCBA9B3','','img','N','2594237','Y','N','0','0','','N']);
+g(['3705346','06-01<br>07:35a<br><font color=red>Running Ball</font>','中国超级联赛','60510','60509','上海绿地申花','重庆斯威','H','0.5','0.860','0.980','O2.5 / 3','U2.5 / 3','1.010','0.810','1.85','3.35','3.60','单','双','1.95','1.94','3705347','H','0 / 0.5','1.010','0.830','O1','U1','1.160','0.660','2.33','4.00','2.27','58','89BCBABCBBBCBABCB9BCB8CCB38CCBCDCBC6CACDCBA9B3','','img','N','2594243','Y','N','0','0','','N']);
+g(['3703220','06-01<br>10:00a<br><font color=red>Running Ball</font>','瑞典超级联赛','60286','60285','IFK哥德堡','奧雷布洛','H','1','0.830','1.070','O2.5 / 3','U2.5 / 3','0.860','1.020','1.46','6.10','4.30','单','双','1.95','1.94','3703221','H','0.5','1.080','0.820','O1 / 1.5','U1 / 1.5','0.730','1.150','2.07','5.30','2.22','62','8EBCBEBCB7CCBABCB9BCB9CCB38CCDC7CEC6CACDCBA9B3','','img','N','2591823','Y','N','0','0','','N']);
+_.gameCount='FT|RB|0,FT|FT|120,FT|FU|150,FT|P3|234,FT|HOT_RB|0,FT|HOT_FT|12,FT|HOT_FU|0,FT|HOT_P3|5,FT|SP_RB|0,FT|SP_FT|0,FT|SP_FU|0,FT|SP_P3|0,BK|RB|0,BK|FT|5,BK|FU|2,BK|P3|6,BK|HOT_RB|0,BK|HOT_FT|0,BK|HOT_FU|0,BK|HOT_P3|0,BK|SP_RB|0,BK|SP_FT|0,BK|SP_FU|0,BK|SP_P3|0,BS|RB|0,BS|FT|21,BS|FU|0,BS|P3|21,BS|HOT_RB|0,BS|HOT_FT|0,BS|HOT_FU|0,BS|HOT_P3|0,BS|SP_RB|0,BS|SP_FT|0,BS|SP_FU|0,BS|SP_P3|0,TN|RB|0,TN|FT|77,TN|FU|21,TN|P3|98,TN|HOT_RB|0,TN|HOT_FT|0,TN|HOT_FU|0,TN|HOT_P3|0,TN|SP_RB|0,TN|SP_FT|0,TN|SP_FU|0,TN|SP_P3|0,VB|RB|0,VB|FT|19,VB|FU|0,VB|P3|19,VB|HOT_RB|0,VB|HOT_FT|0,VB|HOT_FU|0,VB|HOT_P3|0,VB|SP_RB|0,VB|SP_FT|0,VB|SP_FU|0,VB|SP_P3|0,BM|RB|0,BM|FT|0,BM|FU|0,BM|P3|0,BM|HOT_RB|0,BM|HOT_FT|0,BM|HOT_FU|0,BM|HOT_P3|0,BM|SP_RB|0,BM|SP_FT|0,BM|SP_FU|0,BM|SP_P3|0,TT|RB|0,TT|FT|0,TT|FU|0,TT|P3|0,TT|HOT_RB|0,TT|HOT_FT|0,TT|HOT_FU|0,TT|HOT_P3|0,TT|SP_RB|0,TT|SP_FT|0,TT|SP_FU|0,TT|SP_P3|0,OP|RB|0,OP|FT|43,OP|FU|17,OP|P3|56,OP|HOT_RB|0,OP|HOT_FT|0,OP|HOT_FU|0,OP|HOT_P3|0,OP|SP_RB|0,OP|SP_FT|0,OP|SP_FU|0,OP|SP_P3|0,SK|RB|0,SK|FT|0,SK|FU|0,SK|P3|0,SK|HOT_RB|0,SK|HOT_FT|0,SK|HOT_FU|0,SK|HOT_P3|0,SK|SP_RB|0,SK|SP_FT|0,SK|SP_FU|0,SK|SP_P3|0,FS|HOT_FT|0,FS|HOT_BK|0,FS|HOT_BS|0,FS|HOT_TN|0,FS|HOT_VB|0,FS|HOT_BM|0,FS|HOT_TT|0,FS|HOT_OP|0,FS|HOT_SK|0,FS|SP_FT|0,FS|SP_BK|0,FS|SP_BS|0,FS|SP_TN|0,FS|SP_VB|0,FS|SP_BM|0,FS|SP_TT|0,FS|SP_OP|0,FS|SP_SK|0,FS|FT|126,FS|BK|8,FS|BS|3,FS|TN|6,FS|VB|0,FS|BM|0,FS|TT|0,FS|OP|1,FS|SK|0';
+function onLoad(){
+	_.body_var_onLoad();
+}
+
+
+onLoad();

+ 60 - 0
collectSports/mcollect/hg0088/tmpl/zaopan.tmpl

@@ -0,0 +1,60 @@
+
+var parent={};
+var top={};
+
+function checkCorner(item){
+	if(item.split('角球数')>1){
+		return 1;
+	}
+	return 0;
+}
+parent.body_var_onLoad=function(){
+	this.data={};
+	this.data.total_page=this.t_page;
+	this.data.retime=this.retime;
+
+	this.result=[];
+	
+	for(let index in G)
+	{
+		var item=this.GameFT[index];
+		var col_length=item.length;
+		var tmp={};
+		var date=new Date;
+		tmp.match_id=item[0];
+		var tit=item[1];
+		tit=tit.split('<br>');
+		var year=date.getFullYear();
+		tmp.is_roll=0;
+		if(tit.length>2){
+			tmp.is_roll=1;
+		}		
+		tmp.mdate=year+'-'+tit[0];
+		
+		tmp.mtime=tit[1];
+		tmp.half_match_id=item[22];
+		tmp.league_name=item[2];
+		tmp.host_id=item[3];
+		tmp.guest_id=item[4];
+		tmp.host_name=item[5];
+		tmp.guest_name=item[6];
+		tmp.league_id=item[39];
+		tmp.odds_num=item[34];
+		tmp.hot=item[36];
+		tmp.play=item[38];
+		tmp.special=item[45];
+		tmp.ptype=item[44];//联赛附属类型,比如,会晋级,角球数
+		tmp.is_corner=checkCorner(tmp.ptype);
+
+
+		this.result.push(tmp);
+	}
+	this.data.data=this.result;
+	console.log(JSON.stringify(this.data));
+}
+
+
+
+#CONTENT#
+
+onLoad();

+ 0 - 0
collectSports/mcollect/hg3535/__init__.py


+ 103 - 0
collectSports/middlewares.py

@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+
+# Define here the models for your spider middleware
+#
+# See documentation in:
+# https://doc.scrapy.org/en/latest/topics/spider-middleware.html
+
+from scrapy import signals
+
+
+class CollectsportsSpiderMiddleware(object):
+    # Not all methods need to be defined. If a method is not defined,
+    # scrapy acts as if the spider middleware does not modify the
+    # passed objects.
+
+    @classmethod
+    def from_crawler(cls, crawler):
+        # This method is used by Scrapy to create your spiders.
+        s = cls()
+        crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
+        return s
+
+    def process_spider_input(self, response, spider):
+        # Called for each response that goes through the spider
+        # middleware and into the spider.
+
+        # Should return None or raise an exception.
+        return None
+
+    def process_spider_output(self, response, result, spider):
+        # Called with the results returned from the Spider, after
+        # it has processed the response.
+
+        # Must return an iterable of Request, dict or Item objects.
+        for i in result:
+            yield i
+
+    def process_spider_exception(self, response, exception, spider):
+        # Called when a spider or process_spider_input() method
+        # (from other spider middleware) raises an exception.
+
+        # Should return either None or an iterable of Response, dict
+        # or Item objects.
+        pass
+
+    def process_start_requests(self, start_requests, spider):
+        # Called with the start requests of the spider, and works
+        # similarly to the process_spider_output() method, except
+        # that it doesn’t have a response associated.
+
+        # Must return only requests (not items).
+        for r in start_requests:
+            yield r
+
+    def spider_opened(self, spider):
+        spider.logger.info('Spider opened: %s' % spider.name)
+
+
+class CollectsportsDownloaderMiddleware(object):
+    # Not all methods need to be defined. If a method is not defined,
+    # scrapy acts as if the downloader middleware does not modify the
+    # passed objects.
+
+    @classmethod
+    def from_crawler(cls, crawler):
+        # This method is used by Scrapy to create your spiders.
+        s = cls()
+        crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
+        return s
+
+    def process_request(self, request, spider):
+        # Called for each request that goes through the downloader
+        # middleware.
+
+        # Must either:
+        # - return None: continue processing this request
+        # - or return a Response object
+        # - or return a Request object
+        # - or raise IgnoreRequest: process_exception() methods of
+        #   installed downloader middleware will be called
+        return None
+
+    def process_response(self, request, response, spider):
+        # Called with the response returned from the downloader.
+
+        # Must either;
+        # - return a Response object
+        # - return a Request object
+        # - or raise IgnoreRequest
+        return response
+
+    def process_exception(self, request, exception, spider):
+        # Called when a download handler or a process_request()
+        # (from other downloader middleware) raises an exception.
+
+        # Must either:
+        # - return None: continue processing this exception
+        # - return a Response object: stops process_exception() chain
+        # - return a Request object: stops process_exception() chain
+        pass
+
+    def spider_opened(self, spider):
+        spider.logger.info('Spider opened: %s' % spider.name)

+ 11 - 0
collectSports/pipelines.py

@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+
+# Define your item pipelines here
+#
+# Don't forget to add your pipeline to the ITEM_PIPELINES setting
+# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
+
+
+class CollectsportsPipeline(object):
+    def process_item(self, item, spider):
+        return item

+ 0 - 0
collectSports/pipelines/__init__.py


BIN
collectSports/pipelines/__pycache__/__init__.cpython-37.pyc


BIN
collectSports/pipelines/__pycache__/sportslst.cpython-37.pyc


+ 13 - 0
collectSports/pipelines/sportslst.py

@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+
+# Define your item pipelines here
+#
+# Don't forget to add your pipeline to the ITEM_PIPELINES setting
+# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
+
+
+class SportslstPipeline(object):
+    def process_item(self, item, spider):
+        # pass
+        # print(item)
+        return item

+ 90 - 0
collectSports/settings.py

@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+
+# Scrapy settings for collectSports project
+#
+# For simplicity, this file contains only settings considered important or
+# commonly used. You can find more settings consulting the documentation:
+#
+#     https://doc.scrapy.org/en/latest/topics/settings.html
+#     https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
+#     https://doc.scrapy.org/en/latest/topics/spider-middleware.html
+
+BOT_NAME = 'collectSports'
+
+SPIDER_MODULES = ['collectSports.spiders']
+NEWSPIDER_MODULE = 'collectSports.spiders'
+
+
+# Crawl responsibly by identifying yourself (and your website) on the user-agent
+#USER_AGENT = 'collectSports (+http://www.yourdomain.com)'
+
+# Obey robots.txt rules
+ROBOTSTXT_OBEY = False
+
+# Configure maximum concurrent requests performed by Scrapy (default: 16)
+#CONCURRENT_REQUESTS = 32
+
+# Configure a delay for requests for the same website (default: 0)
+# See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
+# See also autothrottle settings and docs
+#DOWNLOAD_DELAY = 3
+# The download delay setting will honor only one of:
+#CONCURRENT_REQUESTS_PER_DOMAIN = 16
+#CONCURRENT_REQUESTS_PER_IP = 16
+
+# Disable cookies (enabled by default)
+#COOKIES_ENABLED = False
+
+# Disable Telnet Console (enabled by default)
+#TELNETCONSOLE_ENABLED = False
+
+# Override the default request headers:
+#DEFAULT_REQUEST_HEADERS = {
+#   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+#   'Accept-Language': 'en',
+#}
+
+# Enable or disable spider middlewares
+# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html
+#SPIDER_MIDDLEWARES = {
+#    'collectSports.middlewares.CollectsportsSpiderMiddleware': 543,
+#}
+
+# Enable or disable downloader middlewares
+# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
+#DOWNLOADER_MIDDLEWARES = {
+#    'collectSports.middlewares.CollectsportsDownloaderMiddleware': 543,
+#}
+
+# Enable or disable extensions
+# See https://doc.scrapy.org/en/latest/topics/extensions.html
+#EXTENSIONS = {
+#    'scrapy.extensions.telnet.TelnetConsole': None,
+#}
+
+# Configure item pipelines
+# See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
+#ITEM_PIPELINES = {
+#    'collectSports.pipelines.CollectsportsPipeline': 300,
+#}
+
+# Enable and configure the AutoThrottle extension (disabled by default)
+# See https://doc.scrapy.org/en/latest/topics/autothrottle.html
+#AUTOTHROTTLE_ENABLED = True
+# The initial download delay
+#AUTOTHROTTLE_START_DELAY = 5
+# The maximum download delay to be set in case of high latencies
+#AUTOTHROTTLE_MAX_DELAY = 60
+# The average number of requests Scrapy should be sending in parallel to
+# each remote server
+#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
+# Enable showing throttling stats for every response received:
+#AUTOTHROTTLE_DEBUG = False
+
+# Enable and configure HTTP caching (disabled by default)
+# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
+#HTTPCACHE_ENABLED = True
+#HTTPCACHE_EXPIRATION_SECS = 0
+#HTTPCACHE_DIR = 'httpcache'
+#HTTPCACHE_IGNORE_HTTP_CODES = []
+#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'

+ 5 - 0
collectSports/spiders/__init__.py

@@ -0,0 +1,5 @@
+# This package will contain the spiders of your Scrapy project
+#
+# Please refer to the documentation for information on how to create and manage
+# your spiders.
+

BIN
collectSports/spiders/__pycache__/__init__.cpython-37.pyc


BIN
collectSports/spiders/__pycache__/sports.cpython-37.pyc


BIN
collectSports/spiders/__pycache__/sportslst.cpython-37.pyc


+ 42 - 0
collectSports/spiders/sports.py

@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+import scrapy
+import lxml.etree
+import pycomm
+
+class SportsSpider(scrapy.Spider):
+    name = 'sports'
+    allowed_domains = ['hg0088.com']
+    # start_urls = ['http://hg0088.com/']
+    custom_settings = {
+        "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
+        "Accept-Encoding":"gzip, deflate",
+        "Accept-Language":"zh-CN,zh;q=0.8",
+        "Cache-Control":"max-age=0",
+        "Connection":"keep-alive",
+        "Cookie":"OddType@21627573=H; protocolstr=http; gamePoint_21627573=2019-05-10%2A0%2A0; _ga=GA1.4.601418716.1557495256; _gid=GA1.4.1118061739.1557495256",
+        "Host":"199.26.100.178",
+        "USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36",
+    }
+
+    start_url= 'http://199.26.100.178/app/member/get_game_allbets.php'
+
+    def start_requests(self):
+            url=self.start_url
+            form_data={
+                "uid":"x5cx6y9fm21627573l266800",
+                "langx":"zh-cn",
+                "gtype":"FT",
+                "showtype":"FT",
+                "gid":"3701122",
+                "ltype":"4",
+                "date":pycomm.gmdate()
+            }
+            request = scrapy.FormRequest(url, formdata=form_data, callback=self.parse)
+            yield request
+
+    def parse(self, response):
+        doc = lxml.etree.fromstring(response.body)  
+        print(doc.xpath('/serverresponse/game/gid//text()'))
+        
+        print(pycomm.getCache('conf'))
+        pass

+ 88 - 0
collectSports/spiders/sportslst.py

@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-
+import scrapy,lxml.etree,pycomm,json
+from collectSports.items import *
+# from mcollect.hg0088 import Resolver
+
+
+class SportslstSpider(scrapy.Spider):
+    curSrc=None
+    name = 'sportslst'
+    allowed_domains = ['hg0088.com']
+    # start_urls = ['http://hg0088.com/']
+    custom_settings = {
+            "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
+            "Accept-Encoding":"gzip, deflate",
+            "Accept-Language":"zh-CN,zh;q=0.8",
+            "Cache-Control":"max-age=0",
+            "Connection":"keep-alive",
+            "Cookie":"OddType@21627573=H; protocolstr=http; gamePoint_21627573=2019-05-10%2A0%2A0; _ga=GA1.4.601418716.1557495256; _gid=GA1.4.1118061739.1557495256",
+            "Host":"199.26.100.178",
+            "USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36",
+            "ITEM_PIPELINES": {
+                "collectSports.pipelines.sportslst.SportslstPipeline": 200,
+            }
+        }
+
+    # start_url= 'http://199.26.100.178/app/member/get_game_allbets.php'
+
+    def start_requests(self):
+        self.curSrc=source=self.getCurrentSource()
+        mc=__import__('mcollect.'+source)
+        srcObj=getattr(mc,source)
+     
+        for item in srcObj.links:
+            url=item['url'].format(uid=srcObj.uid,page=1)
+            if not item['cb']:
+                params='default'
+            else:
+                params=str(item['cb'])
+            request = scrapy.FormRequest(url,  callback=self.parse,meta={'cb':params})
+            yield request
+        
+
+
+    def getCurrentSource(self):
+        conf=pycomm.getCache('conf')
+        if 'currentSource' in conf:
+            return conf['currentSource']
+        return 
+
+    def parse(self, response):
+        cb=response.meta['cb']
+        mc=__import__('mcollect.'+self.curSrc+'.Resolver',fromlist=True)
+        res=mc.Resolver()
+        cbk=getattr(res,cb)
+        re=cbk(response.body)
+        re=json.loads(re)
+        # print(re['total_page'])
+        data=CollectsportsItem()
+        data['zq_league']=data['zq_match']=[]
+
+        for index in re['data']:
+            lg=ZqLeagueItem()
+            lg['league_id']=index['league_id']
+            lg['league_name']=index['league_name']
+            mc=ZqMatch()
+            mc['match_id']=index['match_id']
+            mc['half_match_id']=index['half_match_id']
+            mc['host_id']=index['host_id']
+            mc['guest_id']=index['guest_id']
+            mc['host_name']=index['host_name']
+            mc['guest_name']=index['guest_name']
+            mc['is_half']=0
+            mc['league_id']=index['league_id']
+            mc['is_roll']=index['is_roll'] #是否滚球
+            mc['mdate']=index['mdate']
+            mc['mtime']=index['mtime']
+            mc['is_corner']=index['is_corner']
+            data['zq_match'].append(mc)
+
+            mc['is_half']=1
+            mc['match_id']=index['half_match_id']
+            mc['half_match_id']=0
+            data['zq_match'].append(mc)
+            data['zq_league'].append(lg)
+        yield data
+        
+
+

+ 1 - 0
pycomm/.gitignore

@@ -0,0 +1 @@
+/__pycache__/*.pyc

+ 2 - 0
pycomm/README.md

@@ -0,0 +1,2 @@
+# pycomm
+#DB  Connect 需要安装pymysql,psycopg2,pymongo模块

+ 298 - 0
pycomm/__init__.py

@@ -0,0 +1,298 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+import json,sys
+import codecs
+import os,io
+from urllib import parse, request
+import subprocess
+import asyncio
+import time
+import hashlib
+import random
+import logging
+import logging.config
+import base64
+import datetime
+import tempfile
+_sysCache={}
+# 设定缓存数据
+def setCache(key,value):
+    _sysCache[key]=value
+# 得到缓存数据
+def getCache(key):
+    if key in _sysCache:
+        return _sysCache.get(key)
+    else:
+        return
+def _import(lib,target=-1):
+    if target==-1:
+        return __import__(lib)
+    else:
+        return __import__(lib,fromlist=(target))
+
+# 得到上级绝对路径
+def getAbsPath():
+    return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+def b64encode(enstr):
+    ss = base64.b64encode(enstr.encode('utf-8'))
+    ss = str(ss.decode('utf-8'))
+    return ss
+
+
+def b64decode(destr):
+    ss = base64.b64decode(destr.encode('utf-8'))
+    ss = str(ss.decode('utf-8'))
+    return ss
+
+
+def ldjson(filename):
+    with open(filename, "r") as data:
+        # if data.startswith(u'\ufeff'):
+        #     data = data.encode('utf8')[3:].decode('utf8')
+        data = json.load(data)
+        return data
+    return
+
+
+def md5(md5str):
+    return hashlib.md5(md5str.encode(encoding='UTF-8')).hexdigest()
+
+
+def uri(url):
+    with request.urlopen(url) as f:
+        data = f.read()
+        result = data.decode('utf-8')
+        return json.loads(result)
+
+
+def uri2(url):
+    with request.urlopen(url) as f:
+        data = f.read()
+        result = data.decode('utf-8')
+        return result
+# 加载json文件
+
+
+def loadJson(filename, charset='utf-8'):
+    with open(filename, "r", charset) as data:
+        # if data.startswith(u'\ufeff'):
+        #     data = data.encode('utf8')[3:].decode('utf8')
+        data = json.load(data)
+        return data
+    return
+
+
+# 打开新线程执行
+def asyncExecCmd(cmd):
+    return execApp(cmd, 1)
+
+
+# 解析固定标签
+def parseVar(data):
+    data = data.replace('[RAND]', str(random.random()))
+    data = data.replace('[MSTIME]', str(gmtime() * 1000))
+    data = data.replace('[TIME]', str(gmtime()))
+    data = data.replace('[DATE]', str(gmdate()))
+    return data
+# 执行系统命令
+
+# 解析动态标签
+def parseTag(data,name,value,tag='#'):
+    data = data.replace((tag+name+tag), (value))
+    return data
+
+
+def exejs(cmd, charset='utf-8'):
+    data = __subprocess(cmd)
+    if not data:
+        return ''
+    else:
+        return str(data)
+
+
+def execApp(cmd, isback=0, charset='utf-8'):
+    data = __subprocess(cmd)
+    if isback == 0:
+        pass
+    else:
+        return str(data)
+
+
+def execCmd(cmd, charset='utf-8'):
+    return __subprocess(cmd)
+
+
+def __subprocess(cmd):
+    rt_list=''
+
+    try:
+        # 得到一个临时文件对象, 调用close后,此文件从磁盘删除
+        out_temp = tempfile.TemporaryFile(mode='w+',encoding='utf-8')
+        # 获取临时文件的文件号
+        fileno = out_temp.fileno()
+
+        # 执行外部shell命令, 输出结果存入临时文件中
+        p = subprocess.Popen(cmd, shell=True, stdout=fileno, stderr=fileno)
+        p.wait()
+        # 从临时文件读出shell命令的输出结果
+        out_temp.seek(0)
+        rt = out_temp.read()
+        # 以换行符拆分数据,并去掉换行符号存入列表
+        rt_list = rt.strip().split('\n')
+        
+
+    except Exception as e:
+        print(e)
+    finally:
+        if out_temp:
+            out_temp.close()
+    return ''.join(rt_list)
+
+
+def toLog(message, ftype=0):
+    logger = logging.getLogger()
+    logger.propagate = False
+    filename = time.strftime('%Y-%m-%d', time.localtime(time.time()))
+    filename2 = time.strftime('%H', time.localtime(time.time()))
+    handler = logging.StreamHandler()
+
+    if not os.path.exists("./log/" + filename + "/"):
+        try:
+            os.makedirs("./log/" + filename + "/")
+        except Exception as ex:
+            pass
+    if ftype == 0:
+        ftype = ''
+    else:
+        ftype = ftype+"."
+    handler_file = logging.FileHandler(
+        "./log/" + filename + "/" + ftype + filename2 + ".err")
+    logger.addHandler(handler)
+    logger.addHandler(handler_file)
+    logger.setLevel(logging.NOTSET)
+    nowtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
+    logger.info({'time': nowtime, 'info': message})
+    logger.removeHandler(handler)
+    logger.removeHandler(handler_file)
+
+
+def time2utc(strtime):
+    strtime = time.strptime(strtime, "%Y-%m-%d %H:%M:%S")
+    strtime = int(time.mktime(strtime))
+    return strtime
+
+
+def timeofHmd2utc(hmd):
+    curDate = time.strftime("%Y-%m-%d", time.localtime())
+    checkToTime = time2utc(curDate + ' ' + hmd)
+    return checkToTime
+
+
+def gmtime():
+    return int(time.time())
+
+
+def gmdate():
+    return utc2timestamp(int(time.time()))
+
+
+def saveFile(path, data):
+    with open(path, "w", encoding='utf-8') as f:
+        f.write(data)
+
+
+def appendFile(path, data):
+    with open(path, "a+", encoding='utf-8') as f:
+        f.write(data)
+
+
+def readFile(path):
+    with open(path, "r", encoding='utf8') as f:
+        return f.read()
+    return
+
+
+def utc2timestamp(nowtime):
+    time_local = time.localtime(nowtime)  # 转换成新的时间格式(2016-05-05 20:28:54)
+    dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local)
+    return dt
+
+
+def parseListByXpath(data, path):
+    path = path.split('/')
+    for item in path:
+        if data[item]:
+            data = data[item]
+    return data
+
+
+def postData(url, data):
+
+    textmod = data
+    textmod = parse.urlencode(textmod).encode(encoding='utf-8')
+    pycomm.toLog(textmod, 'post')
+    # 输出内容:user=admin&password=admin
+    header_dict = {
+        'User-Agent':
+        'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+    }
+    try:
+        req = request.Request(url=url, data=textmod, headers=header_dict)
+        res = request.urlopen(req)
+        res = res.read()
+        pycomm.toLog(res, 'post')
+    except Exception as e:
+        # appendFile(os.path.abspath(os.curdir) + '/log/post.log',str({'data':textmod,'url':url}))
+        pycomm.toLog("Unexpected Error: {}".format(e), 'post')
+
+    # 输出内容(python3默认获取到的是16进制'bytes'类型数据 Unicode编码,如果如需可读输出则需decode解码成对应编码):b'\xe7\x99\xbb\xe5\xbd\x95\xe6\x88\x90\xe5\x8a\x9f'
+    # pycomm.toLog(res.decode(encoding='utf-8'))
+    # 输出内容:登录成功
+
+
+def getAsyncLoog():
+    try:
+        loop = asyncio.get_event_loop()
+        if(loop.is_running()):
+            loop = getNewLoop()
+        if(loop.is_closed()):
+            loop = getNewLoop()
+    except Exception as ex:
+        loop = getNewLoop()
+
+
+def asyncExec(tasks):
+    try:
+        loop = asyncio.get_event_loop()
+        if(loop.is_running()):
+            loop = getNewLoop()
+        if(loop.is_closed()):
+            loop = getNewLoop()
+    except Exception as ex:
+        loop = getNewLoop()
+    # 执行coroutine
+    loop.run_until_complete(asyncio.gather(*tasks))
+    loop.close()
+    return loop
+    # loop.close()
+
+
+def getNewLoop():
+    loop = asyncio.new_event_loop()
+    asyncio.set_event_loop(loop)
+    return loop
+# item=[{url:,data:}]
+# 异步提交数据
+
+
+def asyncPost(item):
+    if not item:
+        return
+    tasks = []
+    for it in item:
+        tasks.append(asyncCommit(it['url'], it['data']))
+    asyncExec(tasks)
+
+
+async def asyncCommit(url, data):
+    postData(url, data)

+ 81 - 0
pycomm/db.py

@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+import pymysql
+import psycopg2
+
+
+class DB():
+
+    def __init__(self, DB_HOST, DB_PORT, DB_USER, DB_PWD, DB_NAME, DB='mysql'):
+        self.DB_HOST = DB_HOST  # 设置MYSQL地址
+        self.DB_PORT = DB_PORT  # 设置端口号
+        self.DB_USER = DB_USER  # 设置用户名
+        self.DB_PWD = DB_PWD  # 设置密码
+        self.DB_NAME = DB_NAME  # 数据库名
+        self.DB = DB  # 连接哪种数据库,mysql或者pgsql
+        self.conn = self.getConnection()
+
+    def getConnection(self):
+        # 连接哪种数据库
+        if self.DB == 'pgsql':
+            return psycopg2.connect(
+                host=self.DB_HOST,
+                port=self.DB_PORT,
+                user=self.DB_USER,
+                password=self.DB_PWD,
+                database=self.DB_NAME,
+
+            )
+        elif self.DB == 'mysql':
+            return pymysql.Connect(
+                host=self.DB_HOST,
+                port=self.DB_PORT,
+                user=self.DB_USER,
+                password=self.DB_PWD,
+                database=self.DB_NAME,
+                charset='utf8'
+            )
+        else:
+            raise ("请选择正确连接数据库方式,mysql或者pgsql")
+    def close(self):
+        self._close(self.conn.cursor())
+    # 查询方法
+    def query(self, sqlString):
+        cursor = self.conn.cursor()
+        cursor.execute(sqlString)
+        returnData = cursor.fetchall()
+        # self._close(cursor)
+        return returnData
+
+    # 获取单条数据
+    def find_one(self, sqlString):
+        cursor = self.conn.cursor()
+        cursor.execute(sqlString)
+        returnData = cursor.fetchone()
+        self._close(cursor)
+        return returnData
+
+    # 不带参数的更新方法
+    def update(self, sqlString):
+        cursor = self.conn.cursor()
+        cursor.execute(sqlString)
+        self.conn.commit()
+
+    # 带参数的更新方法
+    def updateByParam(self, sqlString, params):
+        cursor = self.conn.cursor()
+        cursor.execute(sqlString, params)
+        self.conn.commit()
+        self._close(cursor)
+
+    # 关闭回收资源
+    def _close(self, cursor):
+        cursor.close()
+        self.conn.close()
+
+
+# if __name__ == "__main__":
+    # db = DB('localhost', 3306, 'root', '123456', 'zuqiu')
+    # sql = "show create table dc_sclassinfo;"
+    # result = db.query(sql)
+    # pycomm.toLog(result)

+ 51 - 0
pycomm/mongo.py

@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+from pymongo import MongoClient
+import pycomm
+# settings = {
+#     "ip":'192.168.0.113',  # ip
+#     "port":27017,  # 端口
+#     "db_name" : "mydb",  # 数据库名字
+#     "set_name" : "test_set"  # 集合名字
+# }
+
+
+class DBMongo(object):
+
+    def __init__(self, host, dbname, user, pwd, port):
+        try:
+            uri = 'mongodb://' + user + ':' + pwd + '@' + host + ':' + port + '/' + dbname
+            self.conn = MongoClient(uri)
+            self.db = self.conn[dbname]
+
+        except Exception as e:
+            pycomm.toLog(e)
+    # 选定数据集
+    def changeSet(self,setname):
+        return self.db[setname]
+        
+
+
+
+# def main():
+    # mongo = MongoDataBase('192.168.0.250', 'kaiyou','kaiyou', 'ky123456', '27017').changeSet('prize')
+    # pycomm.toLog('no cmd')
+    # dic = {"name": "zhangsan", "age": 18}
+
+    # mongo.insert(dic)
+    # pycomm.toLog(mongo.find_one({"name":"zhangsan"}))
+#     return
+    # dic = {"name":"zhangsan", "age":18}
+    # mongo = MyMongoDB()
+    # mongo.insert(dic)
+    # mongo.dbfind({"name":"zhangsan"})
+
+    # mongo.update({"name":"zhangsan"}, {"$set":{"age":"25"}})
+    # mongo.dbfind({"name":"zhangsan"})
+
+    # mongo.delete({"name":"zhangsan"})
+    # mongo.dbfind({"name":"zhangsan"})
+
+
+# if __name__ == "__main__":
+#     main()

+ 43 - 0
pycomm/redisop.py

@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+import redis
+
+
+class RedisHelper:
+
+    def __init__(self, host1, port1, password1):
+        # 链接服务端        
+        self.__conn = redis.Redis(host=host1, port=port1, password=password1)
+
+    def public(self, channel_public, msg):
+        # 发消息订阅方
+        # publish发消息加入频道chan_pub
+        self.__conn.publish(channel_public, msg)
+        
+    def getConn(self):
+        return self.__conn
+    def subscribe(self, channel_subscribe):
+        # 开始订阅pubsub()
+        # 打开收音机
+        pub = self.__conn.pubsub()
+
+        # 调频道 subscribe
+        pub.subscribe(channel_subscribe)
+
+        # 准备接收parse_response()
+        # 在次调用parse_response() 开始接收
+        pub.parse_response()
+
+        # 返回订阅变量
+        return pub
+
+# obj = RedisHelper()
+
+# # 赋值订阅变量
+# redis_sub = obj.subscribe('kyevent')
+# # obj.public('kyevent', 'hello')
+# # # 循环执行如下命令
+# while True:
+#     # 二次调用parse_response() 开始接收
+#     msg = redis_sub.parse_response()
+#     pycomm.toLog(msg)

+ 58 - 0
pycomm/sqlite.py

@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+# -*- coding: UTF-8 -*-
+import sqlite3
+ 
+ 
+class DBSqlite:
+    """
+    sqlite数据库操作工具类
+    database: 数据库文件地址,例如:db/mydb.db
+    """
+    _connection = None
+ 
+    def __init__(self, database):
+        # 连接数据库
+        self._connection = sqlite3.connect(database)
+ 
+    def _dict_factory(self, cursor, row):
+        d = {}
+        for idx, col in enumerate(cursor.description):
+            d[col[0]] = row[idx]
+        return d
+ 
+    def execute(self, sql, args=[], result_dict=True, commit=True) -> list:
+        """
+        执行数据库操作的通用方法
+        Args:
+        sql: sql语句
+        args: sql参数
+        result_dict: 操作结果是否用dict格式返回
+        commit: 是否提交事务
+        Returns:
+        list 列表,例如:
+        [{'id': 1, 'name': '张三'}, {'id': 2, 'name': '李四'}]
+        """
+        if result_dict:
+            self._connection.row_factory = self._dict_factory
+        else:
+            self._connection.row_factory = None
+        # 获取游标
+        _cursor = self._connection.cursor()
+        # 执行SQL获取结果
+        _cursor.execute(sql, args)
+        if commit:
+            self._connection.commit()
+        data = _cursor.fetchall()
+        _cursor.close()
+        return data
+ 
+ 
+if __name__ == '__main__':
+    # db = DBSqlite('browser.db')
+    # pycomm.toLog(db.execute("select name from sqlite_master where type=?", ['table']))
+    # pycomm.toLog(db.execute("pragma table_info([user])"))
+    # pycomm.toLog(execute("insert into user(id, name, password) values (?, ?, ?)", [2, "李四", "123456"]))
+    # pycomm.toLog(db.execute("select id, name userName, password pwd from user"))
+    # pycomm.toLog(db.execute("select * from user", result_dict=False))
+    # pycomm.toLog(db.execute("select * from user"))
+    pass

+ 11 - 0
scrapy.cfg

@@ -0,0 +1,11 @@
+# Automatically created by: scrapy startproject
+#
+# For more information about the [deploy] section see:
+# https://scrapyd.readthedocs.io/en/latest/deploy.html
+
+[settings]
+default = collectSports.settings
+
+[deploy]
+#url = http://localhost:6800/
+project = collectSports