The general function of this project is to enter the user's account password in the window, crawl the information and display it through tkinter, as shown in the figure:
The crawler part is omitted, mainly to simply encapsulate the crawler function, enter the user account password, and then display the crawled information
# -*- coding: utf-8 -*- import requests import tkinter from bs4 import BeautifulSoup class FindURL(object): def __init__(self): # create the main window self.root = tkinter.Tk() self.root.minsize = (800, 400) self.frame = tkinter.Frame(self.root) self.frame.pack() # set title self.root.title("User Information Query") # Create two input boxes, enter the user account password respectively self.url_input = tkinter.Entry(self.frame, width=20) self.url_input2=tkinter.Entry(self.frame,width=20) # create a display box self.display_info = tkinter.Listbox(self.root, width=50) # create a query button self.result_button = tkinter.Button(self.frame, command=self.spider, text="查询") self.url_input.focus() # Set the position of the input box and button def gui_arrange(self): self.url_input.pack(side=tkinter.TOP) self.url_input2.pack(side=tkinter.TOP) self.display_info.pack() self.result_button.pack(side=tkinter.BOTTOM) # crawler part def spider(self): # get input value self.url = self.url_input.get() self.url2 = self.url_input2.get() # clear the input box self.url_input.delete(0, tkinter.END) self.url_input2.delete(0, tkinter.END) self.display_info.delete(0, tkinter.END) # The crawler part is omitted. . . # Simulate the display content MESSAGE=['Loan amount 20000', 'Loan times 5 times', 'Maximum loan amount 10000', 'Maximum interest 2500'] for i in MESSAGE: self.display_info.insert(tkinter.END, i) return MESSAGE def main(): FL = FindURL () FL.gui_arrange() tkinter.mainloop () pass if __name__ == "__main__": main()