------------------------------------------
window=tk.Tk()
window.title("test windpws")
window.geometry('500x600')
shuru=tk.Entry(window)
shuru.pack(side="top")
t=tk.Text(window,width=60,height=30)
t.pack()
---------------------------------
url = "https://fitgirl-repacks.site/page/"
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
}
dict={}
ls = ["Upcoming repacks","Russian Movies"]
def comd():
var=shuru.get()
for i in range(1,10):
r = requests.get(url+str(i),headers=headers)
soup=BeautifulSoup(r.text,'lxml')
s = soup.find('div',id="content")
#print("******************************第{}页*****************************".format(str(i)))
for j in s.find_all('article',id=re.compile("post-\d+$")):
if var in j.find("h1",class_="entry-title").getText() :
#dict["title"]=j.find("h1",class_="entry-title").getText()
#print(dict["title"])
t.insert("end",str(j.find("h1",class_="entry-title").getText()))
if j.find("ul") is not None:
s=j.find("ul")
for k in s.find_all("li"):
#if s.find_all("li") is not None:
if k.find('a',href=re.compile('^magnet.*?')) is not None:
if k.find('a',href=re.compile('^magnet.*?')).getText() == "magnet":
if len(k.find('a',href=re.compile('^magnet.*?')).get('href')) == 60:
#print(str(k.find('a',href=re.compile('^magnet.*?')).get('href'))+"\n")
t.insert("insert",str(k.find('a',href=re.compile('^magnet.*?')).get('href')))
b1=tk.Button(window,text="检索",width=15,height=4,command=comd)
b1.pack()
window.mainloop()
|