LA.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import json
  2. import requests
  3. import os
  4. from xpinyin import Pinyin
  5. class LA:
  6. def __init__(self, dir):
  7. self.dir = dir
  8. self.lives = []
  9. # 单次爬取json
  10. def loadJson(self, name):
  11. try:
  12. url = f"http://api.hclyz.com:81/mf/json{name}.txt"
  13. # url = f"http://api.maiyoux.com:81/mf/json{name}.txt"
  14. req = requests.get(url)
  15. js = json.loads(req.text)
  16. return js
  17. except:
  18. print(name, "请求失败")
  19. quit()
  20. # 循环爬取所有站点
  21. def circle(self):
  22. for d in self.dir:
  23. self.lives.append(f"【{d}】,#genre#")
  24. if dir[d] == "":
  25. pinyin = Pinyin().get_pinyin(d, '')
  26. else:
  27. pinyin = self.dir[d]
  28. js = self.loadJson(pinyin)
  29. self.lives.extend(f"{j['title']},{j['address']}" for j in js['zhubo'])
  30. self.lives.append("")
  31. print(d, "爬取完成")
  32. # 保存lives
  33. def save(self, savepath):
  34. with open(savepath, 'w') as f:
  35. for live in self.lives:
  36. f.write(live+"\n")
  37. pass
  38. # github上传
  39. def git(path):
  40. """
  41. git add .
  42. git commit -m "注释内容"
  43. git push origin main
  44. :param path:
  45. :return:
  46. """
  47. order_arr = [f"git add {path}", "git commit -m " + '"' + "直播接口" + '"', "git push origin master"]
  48. for order in order_arr:
  49. os.system(order)
  50. if __name__ == '__main__':
  51. # 设置站点
  52. dir = {
  53. "卡哇伊": 'kawayi',
  54. "蜜桃": 'mitao',
  55. "夜妖姬": 'yeyaoji',
  56. "咪咪": 'mimi',
  57. "蚊香社": 'wenxiangshe',
  58. "小辣椒": 'xiaolajiao',
  59. "龙珠": 'longzhu',
  60. "番茄社区": 'fanjiashequ',
  61. "LOVE": 'love',
  62. "小妲己": 'xiaodaji',
  63. "77直播": '77zhibo',
  64. "依依": 'yiyi',
  65. "日出": 'richu',
  66. "彩虹": 'caihong',
  67. "久久": 'jiujiu',
  68. "亚米": 'yami',
  69. "蝶恋": 'dielian',
  70. "映客": 'yingke',
  71. "套路": 'taolu',
  72. "樱花": 'yinghua',
  73. "享色": 'xiangse',
  74. "红浪漫": 'honglangman',
  75. "金鱼": 'jinyu',
  76. "桃花": 'taohua',
  77. "花房": 'huafang',
  78. "小仙女": 'xiaoxiannu',
  79. "视觉秀": 'shijuexiu',
  80. "小天使": 'xiaotianshi',
  81. "一直播": 'yizhibo',
  82. "彩云": '',
  83. "暗语": '',
  84. "娇媚": '',
  85. "黄瓜": '',
  86. "色趣": '',
  87. "糯米": '',
  88. "小蜜蜂": '',
  89. "小红帽": '',
  90. "桃花运": '',
  91. "苦瓜": '',
  92. "爱爱你": '',
  93. "樱花雨i": '',
  94. "盘他": '',
  95. "夜色": '',
  96. "蝴蝶": '',
  97. "小天仙": '',
  98. "杏趣": '',
  99. "小坏蛋": '',
  100. "飘雪": '',
  101. "樱桃": '',
  102. "奥斯卡": 'aosika',
  103. "卡路里": 'kaluli',
  104. "红高粱": '',
  105. "付宝": '',
  106. "小黄书": '',
  107. "二嫂": '',
  108. "花果山": '',
  109. "云鹿": '',
  110. "菠萝": '',
  111. "星宝贝": '',
  112. "夜艳": '',
  113. "七仙女s": 'qixiannus',
  114. "夜来香": '',
  115. "爱零": '',
  116. "十八禁": '',
  117. "兰桂坊": '',
  118. "Dancelife": '',
  119. "小萌猪": '',
  120. "蝴蝶飞": '',
  121. "幽梦": '',
  122. "丽柜厅": '',
  123. "蛟龙": '',
  124. "颜如玉": '',
  125. "橙秀": '',
  126. "鲍鱼l": '',
  127. "小花螺": '',
  128. "皇后": '',
  129. "心之恋": '',
  130. "台妹l": '',
  131. "爱恋": '',
  132. "903娱乐": '',
  133. "尤物岛": '',
  134. "坦克": '',
  135. "好基友": '',
  136. "夜女郎": 'yenulang',
  137. "娇喘": '',
  138. "芒果派": '',
  139. "媚颜": '',
  140. "风流": '',
  141. "夜律": 'yelu',
  142. "玲珑": '',
  143. "浴火": '',
  144. "翠鸟": '',
  145. "幸运星": '',
  146. "她秀": '',
  147. "招财猫": '',
  148. "双碟": '',
  149. "糖果": '',
  150. "么么哒": '',
  151. "小性感": '',
  152. "小喵宠": '',
  153. "兔女郎": 'tunulang',
  154. "睡美人": '',
  155. "金呗": '',
  156. "美夕": '',
  157. "小妖": '',
  158. "约直播": '',
  159. "花仙子": '',
  160. "土豪": '',
  161. "红装": '',
  162. "妞妞": '',
  163. "艳后": '',
  164. "moon": '',
  165. "蓝猫": '',
  166. "美人妆": '',
  167. "入巷": '',
  168. "持久男": '',
  169. "倾心": '',
  170. "小精灵": '',
  171. "偶遇": '',
  172. "灰灰": '',
  173. "猫头鹰": '',
  174. "喜欢你": '',
  175. "夜纯": '',
  176. "杏播": '',
  177. "名流": '',
  178. "花蝴蝶": '',
  179. "咪狐": '',
  180. "牵手": '',
  181. "情趣": '',
  182. "蓝月亮": '',
  183. "小棉袄": ''
  184. }
  185. # lives存储地址
  186. path = "lives/LiveAdult.txt"
  187. savepath = os.path.join(os.getcwd(), path)
  188. # 爬取lives
  189. LA = LA(dir)
  190. js = LA.circle()
  191. # 保存lives
  192. LA.save(savepath)
  193. # 上传git
  194. git(path)