盘搜.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import requests
  7. class Spider(Spider):
  8. def getDependence(self):
  9. return ['py_ali']
  10. def getName(self):
  11. return "py_pansou"
  12. def init(self,extend):
  13. self.ali = extend[0]
  14. print("============py_pansou============")
  15. pass
  16. def isVideoFormat(self,url):
  17. pass
  18. def manualVideoCheck(self):
  19. pass
  20. def homeContent(self,filter):
  21. result = {}
  22. return result
  23. def homeVideoContent(self):
  24. result = {}
  25. return result
  26. def categoryContent(self,tid,pg,filter,extend):
  27. result = {}
  28. return result
  29. def detailContent(self,array):
  30. tid = array[0]
  31. pattern = '(https:\\/\\/www.aliyundrive.com\\/s\\/[^\\\"]+)'
  32. url = self.regStr(tid,pattern)
  33. if len(url) > 0:
  34. return self.ali.detailContent(array)
  35. header = {
  36. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
  37. 'Referer': 'https://www.alipansou.com/s/' +tid
  38. }
  39. rsp = requests.get('https://www.alipansou.com/cv/'+tid, allow_redirects=False, headers=header)
  40. url = self.regStr(reg=r'href=\"(.*)\"', src=rsp.text)
  41. if len(url) == 0:
  42. return ""
  43. url = url.replace('\\','')
  44. newArray = [url]
  45. print(newArray)
  46. return self.ali.detailContent(newArray)
  47. def searchContent(self,key,quick):
  48. map = {
  49. '7':'文件夹',
  50. '1':'视频'
  51. }
  52. ja = []
  53. for tKey in map.keys():
  54. url = "https://www.alipansou.com/search?k={0}&t={1}".format(key,tKey)
  55. rsp = self.fetch(url)
  56. root = self.html(self.cleanText(rsp.text))
  57. aList = root.xpath("//van-row/a")
  58. for a in aList:
  59. title = ''
  60. divList = a.xpath('.//template/div')
  61. t = divList[0].xpath('string(.)')
  62. t = self.cleanText(t).strip()
  63. title = title + t
  64. remark = divList[1].xpath('string(.)')
  65. remark = self.cleanText(remark).replace('\xa0\xa0','').strip().split(' ')[1]
  66. if key in title:
  67. pic = 'https://www.alipansou.com'+ self.xpText(a,'.//van-card/@thumb')
  68. jo = {
  69. 'vod_id': self.regStr(a.xpath('@href')[0],'/s/(.*)'),
  70. 'vod_name': '{0}[{1}]'.format(title,remark),
  71. 'vod_pic': pic
  72. }
  73. ja.append(jo)
  74. result = {
  75. 'list':ja
  76. }
  77. return result
  78. def playerContent(self,flag,id,vipFlags):
  79. return self.ali.playerContent(flag,id,vipFlags)
  80. config = {
  81. "player": {},
  82. "filter": {}
  83. }
  84. header = {}
  85. def localProxy(self,param):
  86. return [200, "video/MP2T", action, ""]