As long as you leave school, the chances of writing are very few, but the chances of signing are very many. If you can't write well, but you can sign a good name, it's also a good choice.
Basic environment configuration
Version: Python 3.6
Modules: tkinter, PIL, requests
tkinter is a built-in module that does not need to be installed
PIL: pip install pillow
requests:pip install requests
Realization effect picture
GUI user interface
--------------------------------------------------------------- //Note: I have a learning base with many learning materials. Interested + Q group: 895817687 --------------------------------------------------------------- from tkinter import * from tkinter import messagebox #create a window root = Tk() #Title root.title('Python Learning group: 516107834') #Window size, width and height root.geometry('600x300') #Window initial position root.geometry('-500+200') #Label control label = Label(root,text = 'autograph',font = ('Chinese script',20),fg = 'blue') label.grid(row =0,column=0) #Design input box entry = Entry(root,font=('Microsoft YaHei',20)) entry.grid(row =0,column=1) #Click button button = Button(root,text = 'Design signature',font=('Microsoft YaHei',22) ,command =download) button.grid(row =1,column=0) #Message loop display window root.mainloop()
Crawling design signature website data
import requests import re #Send request by simulated browser def download(): startUrl ='http://www.uustv.com/' #Get the name entered by the user name = entry.get() #Blanking name = name.strip() if name =='': messagebox.showinfo('Tips:','enter one user name') else: date = { 'word':name, 'sizes':'60', 'fonts':'jfcs.ttf', 'fontcolor':'#000000' } result = requests.post(startUrl,data=date) result.encoding = 'utf-8' #Get the source code of the website html =result.text reg = '<div class="tu">.<img src="(.*?)"/></div>' #Regular expressions (. *?) all need matching imagePath = re.findall(reg,html) #Get the full path of the picture imgUrl = startUrl + imagePath[0] print(imgUrl) #Get picture content response = requests.get(imgUrl).content f = open('{}.gif'.format(name),'wb') f.write(response) #Picture on window bm = ImageTk.PhotoImage(file ='{}.gif'.format(name)) label2= Label(root,image = bm) label2.bm = bm label2.grid(row = 2,columnspan= 2)
Complete code
from tkinter import * from tkinter import messagebox from PIL import Image,ImageTk import requests import re #Send request by simulated browser def download(): startUrl ='http://www.uustv.com/' #Get the name entered by the user name = entry.get() #Blanking name = name.strip() if name =='': messagebox.showinfo('Tips:','enter one user name') else: date = { 'word':name, 'sizes':'60', 'fonts':'jfcs.ttf', 'fontcolor':'#000000' } result = requests.post(startUrl,data=date) result.encoding = 'utf-8' #Get the source code of the website html =result.text reg = '<div class="tu">.<img src="(.*?)"/></div>' #Regular expressions (. *?) all need matching imagePath = re.findall(reg,html) #Get the full path of the picture imgUrl = startUrl + imagePath[0] print(imgUrl) #Get picture content response = requests.get(imgUrl).content f = open('{}.gif'.format(name),'wb') f.write(response) #Picture on window bm = ImageTk.PhotoImage(file ='{}.gif'.format(name)) label2= Label(root,image = bm) label2.bm = bm label2.grid(row = 2,columnspan= 2) #create a window root = Tk() #Title root.title('Python Learning group: 516107834') #Window size, width and height root.geometry('600x300') #Window initial position root.geometry('-500+200') #Label control label = Label(root,text = 'autograph',font = ('Chinese script',20),fg = 'blue') label.grid(row =0,column=0) #Design input box entry = Entry(root,font=('Microsoft YaHei',20)) entry.grid(row =0,column=1) #Click button button = Button(root,text = 'Design signature',font=('Microsoft YaHei',22) ,command =download) button.grid(row =1,column=0) #Message loop display window root.mainloop()