Embarrassed by the ugly signature? Python crawler art signature software

Posted by taldos on Wed, 05 Jan 2022 03:56:50 +0100


Whether you are a college student, a white-collar class who has stepped into the society, or a famous boss in the business world, you will always ask for a signature from time to time. Are you still embarrassed by your ugly signature? No need from now on, because with this article, there is an artist's autograph specially designed for you, which can ensure that you can use it freely in social and business negotiations. Come and have a look!

Python crawler collects website data and makes a signature design small software.

First, let's enter the target address:

You can see that there is a name input box, a drop-down box for font selection, and a design button.

In fact, anyone with some experience can guess that this is a typical post submission data. Of course, it may also be an API. Now let's see what happens to the design web page of the input content point

Conclusion: the web page address has not changed. In this case, we can't find the picture address in the web page source code, even if we can find it

Why can't you do this? Obviously, if you do this, you will always get a signature design with the same name. Because you have no place to submit data (name, font of name).

So let's grab the bag:

Sure enough, it is a post request. Several parameters need to be submitted. These parameters are not encrypted, so we can directly simulate the request to get the source code. After getting the source code, extract the signature image. Finally, if your time is not very tight and you want to improve python quickly, the most important thing is not afraid of hardship. I suggest you can fight ♥ Xin (homonym): 2763177065, that's really good. Many people have made rapid progress. You need to be not afraid of hardship! You can add it and have a look~

Of course, since it is a small software design, I use tkinter module to design software GUI

import requestsfrom tkinter import *import refrom tkinter import messageboxfrom tkinter import ttkfrom PIL import ImageTkfrom urllib.request import urlretrievepath = 'autograph.gif'def get_image():    
# Go to space    
name = e1.get()    
name = name.strip()    
if name == '':        
messagebox.showerror(title='Tips:', message='Please enter a name')    
data = {           
 'word': name,            'sizes': '60',            'fonts': comboxlist.get(),            'fontcolor': '#000000'        
url = 'http://www.uustv.com/'        
req = requests.post(url, data=data)        
req.encoding = req.apparent_encoding        

response = req.text        
reg = re.compile('<div class="tu"><img src="(.*?)"/></div>')        
res = re.findall(reg, response)        
result = url + res[0]        
urlretrieve(result, path)        
# The picture is displayed on the window        
bm = ImageTk.PhotoImage(file=path)        
label2 = Label(root, image=bm)        
label2.bm = bm        
label2.grid(row=2, columnspan=2)
# Create window root = Tk()
# Title root Title ('python learning group: 832357663 ')
# Window size width height root geometry('600x310+500+200')
# Initial position of window
# root.geometry('-500+200')
# Label control l1 = Label(root, text = 'signature', font = ('Chinese block letters', 20), fg='blue')
l1.grid(row=0, column=0)
e1 = Entry(root, width=25, font=('Microsoft YaHei ', 20))
e1.grid(row=0, column=1)
# Click button = Button(root, text = 'design signature', font = ('microsoft YaHei ', 22), command = get_ image)
button.grid(row=1, column=0)
# textvariable=varcomboxlist = ttk.Combobox(root, font = ('Microsoft YaHei', 20), width=2)
comboxlist["values"] = ("jfcs.ttf", "bzcs.ttf", "qmt.ttf",                        "lfc.ttf", "haku.ttf", "zql.ttf", "yqk.ttf")
comboxlist.grid(row=0, column=2)
# Select the first root mainloop()

Topics: Python crawler