├── .gitignore ├── README.md └── iav.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | venvPython/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iav.py 2 | 可搜索javbus、btso的磁力链接和avgle的预览视频 3 | 4 | ## 使用方法 5 | *搜索注意按标准书写番号(如BGN-044)* 6 | 7 | **注意扶梯子!!**(需要修改代码中的proxy_addr) 8 | 9 | 在Javbus上搜索(返回字典)iav.py -b 番号 10 | 11 | 在btso上搜索(返回磁链)iav.py -s 番号 12 | 13 | 在avgle上搜索预览视频 iav.py -v 番号 14 | 15 | ![b.png](https://i.loli.net/2018/04/16/5ad4afd24dec1.png) 16 | ![s.png](https://i.loli.net/2018/04/16/5ad4afd366770.png) 17 | ![v.png](https://i.loli.net/2018/04/16/5ad4afd2f117e.png) 18 | ![h.png](https://i.loli.net/2018/04/16/5ad4afd2f0caf.png) 19 | 20 | ## 需要的东西 21 | * python3 22 | * bs4 23 | 24 | ## License 25 | MIT -------------------------------------------------------------------------------- /iav.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | __author__ = 'WILL_V' 3 | import urllib.request 4 | import urllib.parse 5 | import json 6 | import re 7 | import sys,getopt 8 | from bs4 import BeautifulSoup 9 | 10 | proxy_addr = "127.0.0.1:10808" 11 | 12 | def getPreview(avid): 13 | '''avgle.com获取预览视频''' 14 | AVGLE_SEARCH_JAV_API_URL = 'https://api.avgle.com/v1/jav/{}/{}?limit={}' 15 | url = AVGLE_SEARCH_JAV_API_URL 16 | query = avid 17 | page = 0 18 | limit = 2 19 | proxy = urllib.request.ProxyHandler({'https': proxy_addr}) 20 | opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) 21 | urllib.request.install_opener(opener) 22 | response = json.loads( 23 | urllib.request.urlopen(url.format(urllib.parse.quote_plus(query), page, limit)).read().decode()) 24 | # print(response) 25 | if response['success']: 26 | videos = response['response']['videos'] 27 | print("avgle返回的videos为:") 28 | if (videos!=[]): 29 | print(videos[0]["title"]) 30 | return videos[0]["preview_video_url"] 31 | else: 32 | return "SUCCESS,BUT NOT GET" 33 | else: 34 | return "FAIL" 35 | 36 | def btso(avid): 37 | '''获取btso的磁力链接''' 38 | url = 'https://btso.pw/search/'+avid 39 | proxy = urllib.request.ProxyHandler({'https': proxy_addr}) 40 | opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) 41 | opener.addheaders = [ 42 | ('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36') 43 | ] 44 | urllib.request.install_opener(opener) 45 | soup=BeautifulSoup(urllib.request.urlopen(url).read().decode('utf-8'),'lxml') 46 | listAll=soup.prettify() 47 | pattern = re.compile(r'https://btso.pw/magnet/detail/hash/.*?" title=".*?"') 48 | match = pattern.findall(listAll) 49 | if match: 50 | print('以下数据来自btso.pw:') 51 | for i in match: 52 | i=i.replace('https://btso.pw/magnet/detail/hash/','magnet:?xt=urn:btih:') 53 | print(i.replace('" ',' ')) 54 | else: 55 | print('没有在btso.pw发现',avid,'的数据') 56 | 57 | ''' javbus获取磁力链接的ajax请求 58 | GET /ajax/uncledatoolsbyajax.php?gid=26445925072&lang=zh&img=https://pics.javbus.com/cover/4lqn_b.jpg&uc=0&floor=653 HTTP/1.1 59 | Host: www.javbus.com 60 | Connection: close 61 | Accept: */* 62 | X-Requested-With: XMLHttpRequest 63 | User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 64 | Referer: https://www.javbus.com/HODV-21033 65 | Accept-Encoding: gzip, deflate 66 | Accept-Language: zh-CN,zh;q=0.9,zh-TW;q=0.8 67 | Cookie: 68 | 69 | ''' 70 | 71 | def getAjax(avid): 72 | '''获取javbus的ajax''' 73 | 74 | url='https://www.javbus.com/'+avid 75 | proxy = urllib.request.ProxyHandler({'https': proxy_addr}) 76 | opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) 77 | opener.addheaders = [ 78 | ('User-Agent', 79 | 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'), 80 | ('Host','www.javbus.com'), 81 | ('Connection','close'), 82 | ('X-Requested-With','XMLHttpRequest'), 83 | ('Referer',url) 84 | ] 85 | urllib.request.install_opener(opener) 86 | soup = BeautifulSoup(urllib.request.urlopen(url).read().decode('utf-8'), 'lxml') 87 | html=soup.prettify() 88 | 89 | '''获取img''' 90 | img_pattern = re.compile(r"var img = '.*?'") 91 | match = img_pattern.findall(html) 92 | img=match[0].replace("var img = '","").replace("'","") 93 | print('封面为',img) 94 | 95 | '''获取uc''' 96 | uc_pattern = re.compile(r"var uc = .*?;") 97 | match = uc_pattern.findall(html) 98 | uc = match[0].replace("var uc = ", "").replace(";","") 99 | 100 | '''获取gid''' 101 | gid_pattern = re.compile(r"var gid = .*?;") 102 | match = gid_pattern.findall(html) 103 | gid = match[0].replace("var gid = ", "").replace(";","") 104 | 105 | '''获取ajax''' 106 | ajax="https://www.javbus.com/ajax/uncledatoolsbyajax.php?gid="+gid+"&lang=zh&img="+img+"&uc="+uc 107 | return ajax 108 | 109 | def javbus(avid): 110 | '''获取javbus的磁力链接''' 111 | 112 | url=getAjax(avid) 113 | proxy = urllib.request.ProxyHandler({'https': proxy_addr}) 114 | opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) 115 | opener.addheaders = [ 116 | ('User-Agent', 117 | 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'), 118 | ('Host','www.javbus.com'), 119 | ('Connection','close'), 120 | ('X-Requested-With','XMLHttpRequest'), 121 | ('Referer',url) 122 | ] 123 | urllib.request.install_opener(opener) 124 | soup = BeautifulSoup(urllib.request.urlopen(url).read().decode('utf-8'), 'lxml') 125 | 126 | avdist={'title':'','magnet':'','size':'','date':''} 127 | 128 | for tr in soup.find_all('tr'): 129 | i=0 130 | for td in tr: 131 | if(td.string): 132 | continue 133 | i=i+1 134 | avdist['magnet']=td.a['href'] 135 | if (i%3 == 1): 136 | avdist['title'] = td.a.text.replace(" ", "").replace("\t", "").replace("\r\n","") 137 | if (i%3 == 2): 138 | avdist['size'] = td.a.text.replace(" ", "").replace("\t", "").replace("\r\n","") 139 | if (i%3 == 0): 140 | avdist['date'] = td.a.text.replace(" ", "").replace("\t", "").replace("\r\n","") 141 | print(avdist) 142 | 143 | def main(argv): 144 | print('搜索注意按标准书写番号(如BGN-044)\n') 145 | try: 146 | opts, args = getopt.getopt(argv, "hb:s:v:", ["javbus=", "bt=","vp=="]) 147 | except getopt.GetoptError: 148 | print(''' 149 | 搜索注意按标准书写番号(如BGN-044) 150 | 注意扶梯子 151 | 在Javbus上搜索(返回字典)iav.py -b 番号 152 | 在btso上搜索(返回磁链)iav.py -s 番号 153 | 在avgle上搜索预览视频 iav.py -v 番号 154 | ''') 155 | sys.exit(2) 156 | for opt, arg in opts: 157 | if opt == '-h': 158 | print(''' 159 | 搜索注意按标准书写番号(如BGN-044) 160 | 注意扶梯子 161 | 在Javbus上搜索(返回字典)iav.py -b 番号 162 | 在btso上搜索(返回磁链)iav.py -s 番号 163 | 在avgle上搜索预览视频 iav.py -v 番号 164 | ''') 165 | sys.exit() 166 | elif opt in ("-b", "--javbus"): 167 | avid = arg 168 | javbus(avid) 169 | elif opt in ("-s", "--bt"): 170 | avid = arg 171 | btso(avid) 172 | elif opt in ("-v", "--vp"): 173 | avid = arg 174 | print(getPreview(avid)) 175 | 176 | if __name__ == '__main__': 177 | main(sys.argv[1:]) --------------------------------------------------------------------------------