SoFunction
Updated on 2024-11-16

Python to automate the way to get seed magnet links

Since I had nothing to do, I was going to find a movie to watch. Then I found the seed search site, but these kinds of sites have too many pop-up ads, which annoyed me a lot. So I thought of writing a script to get the magnet link automatically by myself in python.

The whole thing took maybe half an hour to write.

The code is as follows

import requests
import re
from bs4 import BeautifulSoup
 
  
url="*Site of seeds*/"
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":"",
  "Origin":"*Sites for seeds*",
  "Referer":"*Site of seeds*/",
  "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("Enter search term:")
  data={
    "keyword":word,
    "hidden":"true"
    }
  res=(url,data=data,headers=header)
  bs=BeautifulSoup(,"lxml")
  itemInfo=bs.find_all("dd",class_="option")
  torrent={}
  for item in itemInfo:
    magnet=item.find_next("a",href=("magnet.*")).attrs["href"]
    name=item.find_previous("a",href=("*seed's website*/. *\.html")).text
    size=item.find_next(text=("\u6587\u4ef6\u5927\u5c0f")).find_next("b").text
    time=item.find_next(text=("\u6536\u5f55\u65f6\u95f4")).find_next("b").text
    hot=item.find_next(text=("\u4eba\u6c14")).find_next("b").text
    torrent[name]=[name,time,size,hot,magnet]
 
  for item in torrent:
    print("Name:",torrent[item][0])
    print("Published:",torrent[item][1])
    print("Size:",torrent[item][2])
    print("Heat:",torrent[item][3])
    print("Magnetic link:",torrent[item][4],'\n')  

The results of the run are as follows

Above this Python implementation of automatic access to the seed magnet link way is all I have shared with you, I hope to give you a reference, but also hope that you support me more.