磁力链接搜索网站研究心得!

来源:互联网 发布:php 发送http请求 编辑:程序博客网 时间:2024/04/28 17:10

分享近一个月研究DHT协议,xunsearch,并实现出磁力搜索!

磁力搜索分为三部分


第一部分

DHT爬虫模块的实现,该模块负责种子信息的采集入库操作,有2种方案!

1、通过dht协议的node采集hash(40位)通过种子缓存服务器下载种子进行分析,可以自己百度种子服务器的下载方式!

2、通过dht协议的node查询peer列表进行下载分析(推荐)优点 不需要进行第三方下载进行的二次处理。采用开源的torrent库。ubuntu系统直接apt-get install python-libtorrent进行下载。centos安装略麻烦,需要编译boots,libtorrent进行源码安装

      列举从dht协议直接分析torrent信息源码

      if isinstance(alert, lt.metadata_received_alert):
         print 'metadata received'
         handle = alert.handle
         if handle and handle.is_valid():
             self._get_file_info_from_torrent(handle)
            #不需要下载
      session.remove_torrent(handle, True)


if isinstance(alert, lt.metadata_failed_alert):
   handle = alert.handle
   if handle and handle.is_valid():
      self._get_file_info_from_torrent(handle)
      #不需要下载
      session.remove_torrent(handle, True)

def _get_file_info_from_torrent(self, handle):
file_info = {}
        torrent_obj = handle.get_torrent_info()
t_info['name'] = torrent_obj.name()

第二部分

搜索的实现,coreseek考虑到官方停止更新,并且采用空间换时间的概率对与小容量的vps并不是很适合,另外官方的api少的可怜。采用xunsearch开源搜索引擎。各位可以移步xunsearch官网进行查看,生成测试demo非常方便改改样式就能进行订制。


第一篇主要讲解下磁力搜索网站的大体结构和思路方向。

后几篇文章将详细的拆解每一步进行详细的代码说明。

若觉得文章有用请无私的给个赞吧。

附:演示网站地址bt搜索http://www.bttui.com

最后感谢大家的阅读谢谢!

0 0
原创粉丝点击