python实现电影天堂种子磁力的爬取

import requests,re



def getdetail(url):

    response = requests.get(url)
    #dytt的编码为gbk非utf-8
    
    html = response.content.decode('gbk')
    # 电影详情页标题
    movie_title_name = re.search('<h1><font color=#07519a>(.*)</f',html)
    
    movie_title = movie_title_name.group(1)
    # 电影 磁力   magnet
    movie_magnet_url = re.search('/><a href="(.*)"><str',html)
    
    # print(movie_magnet.group(1))
    movie_magnet = movie_magnet_url.group(1)
    # torrent种子
    movie_torrent_url = re.search('ddf"><a href="(.*)">ft',html)
    
    movie_torrent = movie_torrent_url.group(1)
    # print(movie_torrent.group(1))
    # 这个列表用来title
    movie_title_list = []
    movie_title_list.append(movie_title)

    # 这个列表两个下载的链接
    movie_down_url = []
    
    
    movie_down_url.append(movie_magnet)
    
    movie_down_url.append(movie_torrent)
    
    movie_down_url_all = []
    
    movie_down_url_all.append(movie_down_url)

    #保持标题,磁力,种子的同步准确性
    movie_dict = dict(zip(movie_title_list,movie_down_url_all))
    print(movie_dict)



def getpage():
    num = int(input('你要爬取多少页电影呢'))
    #获取每一页的url
    for i in range(1,num):
        lurl = 'http://www.dytt8.net/html/gndy/dyzz/list_23_%s.html' % i

        response = requests.get(lurl)

        html = response.text
        #取出电影详情页的url
        movie_url_list = re.findall('<a href="(.*)" class="ulink"',html)

        for movie_item in movie_url_list:
            movie_url = 'http://www.dytt8.net'+movie_item
            getdetail(movie_url)


if __name__ == '__main__':
    getpage()

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值