因為難看的簽名尷尬?Python爬蟲製作藝術簽名軟件!

前言

不管你是在校大學生,已經踏入社會的白領階層,還是在商界赫赫有名的老總,總會時不時的會要求籤名,您還在為你那難看的簽名而尷尬嗎?從現在起不必了,因為有了這篇文章,在這裡有藝術家親筆為您專門設計的藝術簽名,保證可以讓你在社交,商業洽談中揮灑自如,趕緊來看看吧!

Python爬蟲採集網站數據,製作一款簽名設計小軟件。

首先咱們進入目標地址:

因為難看的簽名尷尬?Python爬蟲製作藝術簽名軟件!

可以看到有一個名字輸入框,一個字體選擇的下拉框,一個設計按鈕。

其實像這種但凡有點經驗都能猜到,這就是典型的post提交數據,當然也有可能是API,現在來看看輸入內容點設計網頁會發生什麼變化

因為難看的簽名尷尬?Python爬蟲製作藝術簽名軟件!

結論:網頁地址沒有變化,這種情況不能去網頁源代碼中查找圖片地址,即使咱們可以找到

因為難看的簽名尷尬?Python爬蟲製作藝術簽名軟件!

為什麼不能夠這樣做呢,很明顯你這樣做的話得到的永遠都是同一個名字的簽名設計。因為你並沒有提交數據(名字,名字的字體)的地方。

所以咱們還是抓包吧:

因為難看的簽名尷尬?Python爬蟲製作藝術簽名軟件!

果然是一個post請求,需要提交幾個參數,這些參數並沒有進行加密,所以咱們直接模擬請求得到源代碼即可,得到源代碼後把簽名圖片提取出來。

當然,既然是一款小軟件設計的話,我這裡用了tkinter模塊來設計軟件GUI

<code>

import

requests

from

tkinter

import

*

import

re

from

tkinter

import

messagebox

from

tkinter

import

ttk

from

PIL

import

ImageTk

from

urllib.request

import

urlretrieve path =

'簽名.gif'

def

get_image

()

:

name = e1.get() name = name.strip() print(comboxlist.get())

if

name ==

''

: messagebox.showerror(title=

'提示:'

, message=

'請輸入名字'

)

else

: 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(

0

] print(result) urlretrieve(result, path) bm = ImageTk.PhotoImage(file=path) label2 = Label(root, image=bm) label2.bm = bm label2.grid(row=

2

, columnspan=

2

) root = Tk() root.title(

'Python學習群:696455390'

) root.geometry(

'600x310+500+200'

) l1 = Label(root, text=

'簽名'

, font=(

'華文行楷'

,

20

), fg=

'blue'

) l1.grid(row=

0

, column=

0

) e1 = Entry(root, width=

25

, font=(

'微軟雅黑'

,

20

)) e1.grid(row=

0

, column=

1

) button = Button(root, text=

'設計簽名'

, font=(

'微軟雅黑'

,

22

) , command=get_image) button.grid(row=

1

, column=

0

) comboxlist = ttk.Combobox(root, font=(

'微軟雅黑'

,

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

) comboxlist.current(

0

) root.mainloop() /<code>


分享到:


相關文章: