| 6 | import json |
| 7 | |
| 8 | class Spider(Spider): # 元类 默认的元类 type |
| 9 | def getName(self): |
| 10 | return "x小猫咪" |
| 11 | def init(self,extend=""): |
| 12 | print("============{0}============".format(extend)) |
| 13 | pass |
| 14 | def isVideoFormat(self,url): |
| 15 | pass |
| 16 | def manualVideoCheck(self): |
| 17 | pass |
| 18 | def homeContent(self,filter): |
| 19 | result = {} |
| 20 | cateManual = { |
| 21 | "电影":"1", |
| 22 | "电视剧":"2", |
| 23 | "综艺":"3", |
| 24 | "动漫":"4", |
| 25 | "纪录":"5" |
| 26 | } |
| 27 | classes = [] |
| 28 | for k in cateManual: |
| 29 | classes.append({ |
| 30 | 'type_name':k, |
| 31 | 'type_id':cateManual[k] |
| 32 | }) |
| 33 | result['class'] = classes |
| 34 | if(filter): |
| 35 | result['filters'] = self.config['filter'] |
| 36 | return result |
| 37 | def homeVideoContent(self): |
| 38 | tmpRsp = self.fetch("https://xmaomi.net/") |
| 39 | suffix = self.regStr(tmpRsp.text,"window.location.href =\"(\\S+)\"") |
| 40 | url = "https://xmaomi.net"+suffix |
| 41 | # self.cookie = rsp.cookies |
| 42 | rsp = self.fetch(url,cookies=tmpRsp.cookies) |
| 43 | root = self.html(rsp.text) |
| 44 | print(rsp.text[0]) |
| 45 | print(root) |
| 46 | aList = root.xpath("//ul[contains(@class,'hl-vod-list')]/li/a") |
| 47 | videos = [] |
| 48 | for a in aList: |
| 49 | name = a.xpath('./@title')[0] |
| 50 | pic = a.xpath('./@data-original')[0] |
| 51 | mark = a.xpath("./div[@class='hl-pic-text']/span/text()")[0] |
| 52 | sid = a.xpath("./@href")[0] |
| 53 | sid = self.regStr(sid,"/(\\S+).html") |
| 54 | videos.append({ |
| 55 | "vod_id":sid, |
| 56 | "vod_name":name, |
| 57 | "vod_pic":pic, |
| 58 | "vod_remarks":mark |
| 59 | }) |
| 60 | result = { |
| 61 | 'list':videos |
| 62 | } |
| 63 | return result |
| 64 | def categoryContent(self,tid,pg,filter,extend): |
| 65 | result = {} |
nothing calls this directly
no outgoing calls
no test coverage detected