Python抓取美剧天堂bt

作者: 小白不白wzb | 来源:发表于2016-05-09 00:43 被阅读0次

使用urllib,urllib2,beautifulsoup.

执行下面代码,输入要查找的美剧名即可:

查询到所有结果并遍历每一个结果中不同视频格式的所有下载链接

# coding: utf-8

import urllib

import urllib2

from bs4 import BeautifulSoup

import sys

reload(sys)

sys.setdefaultencoding('utf8')

host= "http://www.meijutt.com"

def getUrlRespHtml(url,data=None):

   heads = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

           'Accept-Charset':'GB2312,utf-8;q=0.7,*;q=0.7',

           'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',

           'Cache-Control':'max-age=0',

           'Host':host,

           'Connection':'keep-alive',

           'Referer':url,

           'User-Agent':'Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.14) Gecko/20110221 Ubuntu/10.10 (maverick) Firefox/3.6.14'}

   req = urllib2.Request(url)

   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())

   opener.addheaders = heads.items()

   if data:

       data = urllib.urlencode(data)

       respHtml = opener.open(req,data).read()

   else:

       respHtml = opener.open(req).read()

   return respHtml

def get_bt(url):

   html = getUrlRespHtml(url)

   bs_html = BeautifulSoup(html)

   download_list = bs_html.find_all('div','down_list')

   for index,down_list in enumerate(download_list):

       if len(download_list)>1:

           print '<<<<<视频格式%s>>>>>'%(index+1)

       for li in down_list.find_all('li'):

           f_attrs = li.find('input','down_url').attrs

           print f_attrs.get('value')

def get_bts(searchword):

   data ={'searchword':searchword}

   url = host+'/search.asp'

   html=getUrlRespHtml(url,data)

   bs = BeautifulSoup(html)

   cn_box2 = bs.find_all('div','cn_box2')

   print '\n搜索结果:%s\n'%len(cn_box2)

   for index,div in enumerate(cn_box2):

       print '------搜索结果%s------'%(index+1)

       attrs = div.a.attrs

       title = attrs.get('title')

       href = attrs.get('href')

       print title,(host+href)

       get_bt(host+href)

       print '------end--------\n'

searchword=raw_input("请输入要搜索的美剧:")

get_bts(searchword.encode('gb2312'))

相关文章

  • Python抓取美剧天堂bt

    使用urllib,urllib2,beautifulsoup. 执行下面代码,输入要查找的美剧名即可: 查询到所有...

  • 资源网站收藏

    资源网站: BT之家 电影FM 高清Mp4吧 BT天堂 4567高清视界 海盗湾 kat.cr EZTV(美剧) ...

  • BT相关

    BT影视资源 比特大雄BT之家磁力熊BT首发BT吧BT电影天堂BT世界高清啦BT之家 磁力 磁力狗磁力猪磁力蜘蛛

  • 美剧时光_好看的美剧_美剧爱好者的天堂|美剧时光官方网站

    好看的美剧,美剧推荐,美剧在线观看,天天美剧,美剧天堂,美剧时光官方网站 美剧时光官方网站(imeijuti...

  • 42个超免费追剧app

    美剧: 1.人人影视 2.胖鸟电影网 3.美剧天堂 4.美剧TV 5.麻花美剧 6...

  • Python实用练手小案例

    抓取网页信息,并生成txt文件内容!Python抓取网页技能——Python抓取网页就是我们常看见的网络爬虫,我们...

  • 小电影好看吗?Python实现BT种子转化为磁力链接!

    Python实现BT种子转化为磁力链接【实战】 经常看电影的朋友肯定对BT种子并不陌生,但是BT种子文件相对磁力链...

  • 爬取美剧天堂

    概述 有时候会看看美剧,所以回到美剧天堂去下载一些美剧看看。所以想怕网站的美剧都爬取出来 页面分析 网站是分为6类...

  • BT天堂全站种子

    已失效 今天想下电影,发现BT天堂上的资源还挺全的,但是有个问题,想下个电影,需要经过好几个步骤,略显麻烦,索性自...

  • Android 抓取蓝牙hci日志方法

    抓取HCI日志方法手机必须是root版本将手机目录中的/etc/bluetooth/bt_stack.conf文件...

网友评论

    本文标题:Python抓取美剧天堂bt

    本文链接:https://www.haomeiwen.com/subject/awterttx.html