#!/usr/bin/python
# coding: UTF-8
import requests
from bs4 import BeautifulSoup
import re
print("请输入番号")
fh = input("番号是:")
print(fh)
link1 = "https://www.sobt5.vip/q/"+fh+".html"
headlink = "https://www.sobt5.vip"
def GetLink(link):
headers = {'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
r = requests.get(link, headers= headers)
r.encoding = r.apparent_encoding
html_doc = r.text
soup = BeautifulSoup(html_doc,"html.parser")
pattern = re.compile(r'a href="(\S+.html)"\s+target=')
result1 = pattern.findall(html_doc)
return result1
def GetTorrent(link):
headers = {'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
r = requests.get(link, headers= headers)
r.encoding = r.apparent_encoding
html_doc = r.text
soup = BeautifulSoup(html_doc,"html.parser")
pattern = re.compile(r'<input id="m_link" value="(\S+)" readonly')
result2 = pattern.findall(html_doc)
return result2
##
rs1 = GetLink(link1)
for each in rs1:
link2 = headlink+each
rs2 = GetTorrent(link2)
for each in rs2:
print(each)