亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python如何爬取個(gè)性簽名

 更新時(shí)間:2018年06月19日 09:44:14   作者:吾碎汝夢(mèng)丶S1  
這篇文章主要為大家詳細(xì)介紹了pythonx抓取個(gè)性簽名的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

思路

改進(jìn)原博主文章(Python GUI–Tkinter簡(jiǎn)單實(shí)現(xiàn)個(gè)性簽名設(shè)計(jì))的代碼,原先的代碼是基于Python2的,我這份代碼基于Python3 并針對(duì)當(dāng)前的網(wǎng)站做了相應(yīng)調(diào)整

前置要求

Python 3.X
tkinter
PIL

完整代碼

# -*- coding:utf-8 -*-

from tkinter import *
import tkinter
import requests
import re
from PIL import Image


def download():
  start_url = 'http://www.uustv.com/'
  name = entry.get().encode('utf-8')
  if not name:
    return
  data = {
    'word': name,
    'sizes': '60',
    'fonts': 'jfcs.ttf', # 個(gè)性簽
    # 'fonts': 'qmt.ttf', # 連筆簽
    # 'fonts': 'bzcs.ttf', # 瀟灑簽
    # 'fonts': 'lfc.ttf', # 草體簽
    # 'fonts': 'haku.ttf', # 合文簽
    # 'fonts': 'zql.ttf', # 商務(wù)簽
    # 'fonts': 'yqk.ttf', # 可愛簽
    'fontcolor': '#00FF00'
  }
  result = requests.post(start_url, data=data).content
  # 截止20180302 網(wǎng)站CSS變動(dòng)
  reg = '<div class="tu">.*<img src="(.*?)"/></div>'
  # byte轉(zhuǎn)string
  result = bytes.decode(result)
  img_url = start_url+re.findall(reg, result)[0]
  # 避免了原代碼在Win下無法正常寫入文件的問題
  name = 'tmp'
  response = requests.get(img_url).content
  with open('{}.gif'.format(name), 'wb') as f:
    f.write(response)
  try:
    im = Image.open('{}.gif'.format(name))
    im.show()
  except Exception as e:
    raise e


root = tkinter.Tk()
root.title('個(gè)性簽名設(shè)計(jì)')
root.geometry('+800+300')
Label(root, text='姓名', font=('微軟雅黑', 15)).grid()
entry = Entry(root, font=('微軟雅黑', 15))
entry.grid(row=0, column=1)
button = Button(root, text='設(shè)計(jì)簽名', font=('微軟雅黑', 15),
        width='15', height=1, command=download)
button.grid(row=1, column=1)
root.mainloop()

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論