def btdb_parse(fanhao, proxy_headers): global btdb_fanhaos btdb_fanhaos = [] try: fanhao_url = 'http://btdb.in/q/%s/' % urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return btdb_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find_all("li", attrs={"class": "search-ret-item"}) if soup_items: for item in soup_items: title = item.find("h1").find("a").get("title") info = item.find("div", attrs={ "class": "item-meta-info" }).find_all("span", attrs={"class": "item-meta-info-value"}) file_size = info[0].text downloading_count = int(info[-1].text) file_number = int(info[1].text) magnet_url = item.find("div", attrs={ "class": "item-meta-info" }).find("a", attrs={ "class": "magnet" }).get("href") resource = 'BTDB' resource_url = 'http://btdb.in' fanhao = FanHao(title, file_size, downloading_count, file_number, magnet_url, resource, resource_url) btdb_fanhaos.append(fanhao) return btdb_fanhaos
def Qululu_parse(fanhao, proxy_headers): global Qululu_fanhaos Qululu_fanhaos = [] try: fanhao_url = 'http://www.qululu.cn/search1/b/%s/1/hot_d' % fanhao.decode( sys.stdin.encoding).encode('utf8').encode('hex') proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return Qululu_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find("ul", attrs={"class": "mlist"}).find_all("li") if soup_items: for item in soup_items: title = item.find("div", attrs={"class": "T1"}).find("a").string title = re.sub('<span class="mhl">', '', re.sub('</span>', '', title.decode('hex'))) info = item.find("dl", attrs={ "class": "BotInfo" }).find("dt").find_all("span") file_size = info[0].string.replace(' ', '') file_number = int(info[1].string) downloading_count = int(info[3].string) magnet_url = item.find("div", attrs={ "class": "dInfo" }).find("a").get('href') resource = 'Qululu' resource_url = 'http://www.qululu.cn' fanhao = FanHao(title, file_size, downloading_count, file_number, magnet_url, resource, resource_url) Qululu_fanhaos.append(fanhao) return Qululu_fanhaos
def cili_parse(fanhao, proxy_headers): global cili_fanhaos cili_fanhaos = [] try: fanhao_url = 'http://www.cili.tv/search/%s_ctime_1.html' % urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=5) fanhao_html = response.read() except Exception: return cili_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find_all("div", attrs={"class": "item"}) if soup_items: for item in soup_items: title = item.a.text.strip() info = item.find("div", attrs={"class": "info"}) spans = info.find_all("span") file_size = str(spans[1].b.text) downloading_count = int(str(spans[2].b.string)) magnet_url = str(spans[3].find("a").get('href')) resource = 'Cili' resource_url = 'http://www.cili.tv' fanhao = FanHao(title, file_size, downloading_count, None, magnet_url, resource, resource_url) cili_fanhaos.append(fanhao) return cili_fanhaos
def micili_parse(fanhao, proxy_headers): global micili_fanhaos micili_fanhaos = [] try: fanhao_url = 'http://www.micili.com/list/' + urllib.quote( fanhao.decode( sys.stdin.encoding).encode('utf8')) + '/?c=&s=create_time' proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return micili_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find("ul", attrs={ "class": "collection z-depth-1" }).find_all("li") if soup_items: for item in soup_items: title = item.find("h6").find("a").get('title') info = item.find("span", attrs={"class": "mt10"}) file_number = int(info.text.split(':')[1].split(u'大小')[0].strip()) file_size = info.text.split(':')[2].split(u'请求数')[0].strip() downloading_count = int( info.text.split(u'请求数:')[1].split(u'磁力链接')[0].strip()) magnet_url = info.find("a").get('href') resource = 'micili' resource_url = 'http://www.micili.com' fanhao = FanHao(title, file_size, downloading_count, file_number, magnet_url, resource, resource_url) micili_fanhaos.append(fanhao) return micili_fanhaos
def btku_parse(fanhao, proxy_headers): global btku_fanhaos btku_fanhaos = [] try: fanhao_url = 'http://www.btku.me/q/%s/' % urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return btku_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find("div", attrs={ "id": "search_Results" }).find_all("li", attrs={"class": "results"}) if soup_items: for item in soup_items: title = item.find("h2").find("a").text info = item.find("p", attrs={"class": "resultsIntroduction"}) file_number = int(info.find_all("label")[0].string) file_size = info.find_all("label")[1].string downloading_count = int(info.find_all("label")[2].string) magnet_url = info.find("span", attrs={ "class": "downLink" }).find_all("a")[1].get('href') resource = 'BTKU' resource_url = 'http://www.btku.me' fanhao = FanHao(title, file_size, downloading_count, file_number, magnet_url, resource, resource_url) btku_fanhaos.append(fanhao) return btku_fanhaos
def zhongziIn_parse(fanhao, proxy_headers): global zhongziIn_fanhaos zhongziIn_fanhaos = [] try: fanhao_url = 'http://www.zhongzi.in/s/' + urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return zhongziIn_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find("div", attrs={"class": "wx_list"}).find_all("li") if soup_items: for item in soup_items: title = item.find("a").get('title') info = item.find("span", attrs={"class": "j_size"}) file_size = info.text.split(":")[1] magnet_url = info.find("a").get('href') resource = 'zhongzi.in' resource_url = 'http://www.zhongzi.in' fanhao = FanHao(title, file_size, None, None, magnet_url, resource, resource_url) zhongziIn_fanhaos.append(fanhao) return zhongziIn_fanhaos
def btbook_parse(fanhao, proxy_headers): global btbook_fanhaos btbook_fanhaos = [] try: fanhao_url = 'http://www.btbook.net/search/' + urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) + '.html' proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return btbook_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find_all("div", attrs={"class": "search-item"}) if soup_items: for item in soup_items: title = item.find("h3").find("a").find("b").text info = item.find("div", attrs={ "class": "item-bar" }).find_all("span") file_size = info[2].b.text downloading_count = int(info[3].b.text) magnet_url = item.find("div", attrs={ "class": "item-bar" }).find("a").get("href") resource = 'Btbook' resource_url = 'http://www.btbook.net' fanhao = FanHao(title, file_size, downloading_count, None, magnet_url, resource, resource_url) btbook_fanhaos.append(fanhao) return btbook_fanhaos
def nimasou_parse(fanhao, proxy_headers): global nimasou_fanhaos nimasou_fanhaos = [] try: fanhao_url = 'http://www.nimasou.com/l/%s-hot-desc-1' % urllib.request.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib.request.Request(fanhao_url, headers=proxy_headers) response = urllib.request.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return nimasou_fanhaos soup = BeautifulSoup(fanhao_html, "html.parser") try: soup_items = soup.find("table", attrs={ "class": "table" }).find_all("tr") except Exception: return nimasou_fanhaos if soup_items: for item in soup_items: title = item.find("td", attrs={ "class": "x-item" }).find("a", attrs={ "class": "title" }).text info = item.find("td", attrs={ "class": "x-item" }).find("div", attrs={ "class": "tail" }).text.split(':') file_size = info[2].split(' ')[1] + info[2].split(' ')[2] downloading_count = int(info[3].split(' ')[1]) magnet_url = item.find("td", attrs={ "class": "x-item" }).find("div", attrs={ "class": "tail" }).find("a").get('href') resource = 'NiMaSou' resource_url = 'http://www.nimasou.com' fanhao = FanHao(title, file_size, downloading_count, None, magnet_url, resource, resource_url) nimasou_fanhaos.append(fanhao) return nimasou_fanhaos
def btcherry_parse(fanhao, bt_page, proxy_headers): globals()['btcherry_fanhaos_%s' % str(bt_page)] = [] try: fanhao_url = 'http://www.btcherry.net/search?keyword=' + urllib.request.quote( fanhao.decode( sys.stdin.encoding).encode('utf8')) + '&p=' + str(bt_page) proxy_request = urllib.request.Request(fanhao_url, headers=proxy_headers) response = urllib.request.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return globals()['btcherry_fanhaos_%s' % str(bt_page)] soup = BeautifulSoup(fanhao_html, "html.parser") soup_items = soup.find_all("div", attrs={"class": "r"}) if soup_items: for item in soup_items: try: title = item.find("h5", attrs={"class": "h"}).text if title.rfind('> */@') > 0: title = title[title.rfind("> */@") + 5:] elif title.rfind('> */]@') > 0: title = title[title.rfind("> */]@") + 6:] if title.rfind('> */') > 0: title = title[title.rfind("> */") + 4:] info = item.find("div").find_all("span") file_size = info[2].find("span", attrs={ "class": "prop_val" }).text file_number = int(info[4].find("span", attrs={ "class": "prop_val" }).text) magnet_url = item.find("div").find("a").get("href") except Exception: pass resource = 'BTCherry' resource_url = 'http://www.btcherry.net' fanhao = FanHao(title, file_size, None, file_number, magnet_url, resource, resource_url) globals()['btcherry_fanhaos_%s' % str(bt_page)].append(fanhao) return globals()['btcherry_fanhaos_%s' % str(bt_page)]
def btcherry_parse(fanhao, proxy_headers): global btcherry_fanhaos btcherry_fanhaos = [] try: fanhao_url = 'http://www.btcherry.net/search?keyword=' + urllib.quote( fanhao.decode(sys.stdin.encoding).encode('utf8')) proxy_request = urllib2.Request(fanhao_url, headers=proxy_headers) response = urllib2.urlopen(proxy_request, timeout=10) fanhao_html = response.read() except Exception: return btcherry_fanhaos soup = BeautifulSoup(fanhao_html) soup_items = soup.find_all("div", attrs={"class": "r"}) if soup_items: for item in soup_items: try: title = item.find("h5", attrs={"class": "h"}).text info = item.find("div").find_all("span") file_size = info[2].find("span", attrs={ "class": "prop_val" }).text file_number = int(info[4].find("span", attrs={ "class": "prop_val" }).text) magnet_url = item.find("div").find("a").get("href") except Exception: pass resource = 'BTCherry' resource_url = 'http://www.btcherry.net' fanhao = FanHao(title, file_size, None, file_number, magnet_url, resource, resource_url) btcherry_fanhaos.append(fanhao) return btcherry_fanhaos