| 7 | from abc import abstractmethod,ABCMeta |
| 8 | from importlib.machinery import SourceFileLoader |
| 9 | class Spider(metaclass=ABCMeta): |
| 10 | _instance = None |
| 11 | def __new__(cls, *args, **kwargs): |
| 12 | if cls._instance: |
| 13 | return cls._instance |
| 14 | else: |
| 15 | cls._instance = super().__new__(cls) |
| 16 | return cls._instance |
| 17 | @abstractmethod |
| 18 | def init(self,extend=""):pass |
| 19 | @abstractmethod |
| 20 | def homeContent(self,filter):pass |
| 21 | @abstractmethod |
| 22 | def homeVideoContent(self):pass |
| 23 | @abstractmethod |
| 24 | def categoryContent(self,tid,pg,filter,extend):pass |
| 25 | @abstractmethod |
| 26 | def detailContent(self,ids):pass |
| 27 | @abstractmethod |
| 28 | def searchContent(self,key,quick):pass |
| 29 | @abstractmethod |
| 30 | def playerContent(self,flag,id,vipFlags):pass |
| 31 | @abstractmethod |
| 32 | def localProxy(self,param):pass |
| 33 | @abstractmethod |
| 34 | def isVideoFormat(self,url):pass |
| 35 | @abstractmethod |
| 36 | def manualVideoCheck(self):pass |
| 37 | @abstractmethod |
| 38 | def getName(self):pass |
| 39 | def getDependence(self): |
| 40 | return [] |
| 41 | def regStr(self,src,reg,group=1): |
| 42 | m = re.search(reg, src) |
| 43 | src = '' |
| 44 | if m : |
| 45 | src = m.group(group) |
| 46 | return src |
| 47 | def str2json(self,str): |
| 48 | return json.loads(str) |
| 49 | def cleanText(self,src): |
| 50 | clean = re.sub('[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F1E0-\U0001F1FF]', '', src) |
| 51 | return clean |
| 52 | def fetch(self,url,headers={},cookies=""): |
| 53 | rsp = requests.get(url,headers=headers,cookies=cookies) |
| 54 | rsp.encoding='utf-8' |
| 55 | return rsp |
| 56 | def post(self,url,data,headers={},cookies={}): |
| 57 | rsp = requests.post(url,data=data,headers=headers,cookies=cookies) |
| 58 | rsp.encoding='utf-8' |
| 59 | return rsp |
| 60 | def postJson(self,url,json,headers={},cookies={}): |
| 61 | rsp = requests.post(url,json=json,headers=headers,cookies=cookies) |
| 62 | rsp.encoding='utf-8' |
| 63 | return rsp |
| 64 | def html(self,content): |
| 65 | return etree.HTML(content) |
| 66 | def xpText(self,root,expr): |
nothing calls this directly
no outgoing calls
no test coverage detected