Python 實現(xiàn)自動獲取種子磁力鏈接方式
更新時間:2020年01月16日 14:59:26 作者:錦城花開
今天小編就為大家分享一篇Python 實現(xiàn)自動獲取種子磁力鏈接方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
因為我閑來無事,所以準備找一部電影來看看。 然后我找到了種子搜索網(wǎng)站,可是這類網(wǎng)站的彈窗廣告太多,搞得我很煩。所以我就想著自己用python寫一個自動獲取磁力鏈接的腳本。
整個大概寫了半個小時。
代碼如下
import requests
import re
from bs4 import BeautifulSoup
url="*種子的網(wǎng)站*/"
header={
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding":"gzip, deflate",
"Accept-Language":"zh-CN,zh;q=0.8",
"Cache-Control":"max-age=0",
"Connection":"keep-alive",
"Content-Length":"65",
"Content-Type":"application/x-www-form-urlencoded",
"Host":"btkitty.bid",
"Origin":"*種子的網(wǎng)站*",
"Referer":"*種子的網(wǎng)站*/",
"Upgrade-Insecure-Requests":"1",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0.14393; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2950.5 Safari/537.36"
}
while True:
word=input("輸入搜索關鍵詞:")
data={
"keyword":word,
"hidden":"true"
}
res=requests.post(url,data=data,headers=header)
bs=BeautifulSoup(res.text,"lxml")
itemInfo=bs.find_all("dd",class_="option")
torrent={}
for item in itemInfo:
magnet=item.find_next("a",href=re.compile("magnet.*")).attrs["href"]
name=item.find_previous("a",href=re.compile("*種子的網(wǎng)站*/.*\.html")).text
size=item.find_next(text=re.compile("\u6587\u4ef6\u5927\u5c0f")).find_next("b").text
time=item.find_next(text=re.compile("\u6536\u5f55\u65f6\u95f4")).find_next("b").text
hot=item.find_next(text=re.compile("\u4eba\u6c14")).find_next("b").text
torrent[name]=[name,time,size,hot,magnet]
for item in torrent:
print("名稱:",torrent[item][0])
print("發(fā)布時間:",torrent[item][1])
print("大?。?,torrent[item][2])
print("熱度:",torrent[item][3])
print("磁力鏈接:",torrent[item][4],'\n')
運行結(jié)果如下

以上這篇Python 實現(xiàn)自動獲取種子磁力鏈接方式就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Python獲取當前公網(wǎng)ip并自動斷開寬帶連接實例代碼
這篇文章主要介紹了Python獲取當前公網(wǎng)ip并自動斷開寬帶連接實例代碼,具有一定借鑒價值,需要的朋友可以參考下2018-01-01
Python切換pip源兩種方法(解決pip?install慢)
這篇文章主要給大家介紹了關于Python切換pip源兩種方法(解決pip?install慢),我總結(jié)的這幾種更換pip源的常用方式,希望可以幫助您成功配置國內(nèi)源,解決安裝Python包速度慢的問題,需要的朋友可以參考下2023-11-11
Python多進程方式抓取基金網(wǎng)站內(nèi)容的方法分析
這篇文章主要介紹了Python多進程方式抓取基金網(wǎng)站內(nèi)容的方法,結(jié)合實例形式分析了Python多進程抓取網(wǎng)站內(nèi)容相關實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下2019-06-06

