Get the App
SLTechnology News&Howtos  ›  Development  › 

How to develop personal emojis website by Python

Shulou Source: shulou.com Published: 2022-06-02 13:13:39 09月16日 Update

This article mainly introduces "how to develop a personal meme website by Python". In daily operation, I believe that many people have doubts about how to develop a personal meme website by Python. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to develop a personal meme website by Python". Next, please follow the editor to study!

Environment: Windows+Python3.6

IDE: personal preference

Module

Import requestsimport reimport pymysq

Complete code

Import requestsimport reimport pymysql# connects to the database db = pymysql.connect (host = '127.0.0.1) database db =' db',user = 'root',passwd =' root' Charset = 'utf8') # create cursor cursor = db.cursor () # cursor.execute (' select * from images') # print (cursor.fetchall ()) # Little Hump # comment get picture list def getImagesList (page): # get Doutu source code html = requests.get ('http://www.doutula.com/photo/list/?page={}'.format(page)).text # regular expression wildcard. *? Match all groups match reg = (. *?) ". *? alt=" (. *?) "'# S multi-line matching reg = re.compile (reg,re.S) imagesList = re.findall (reg) Html) for i in imagesList: image_url = I [0] image_title = I [1] # format string format% s cursor.execute ("insert into images (`name`, `imageUrl`) values ('{}','{}')" .format (image_title,image_url)) print ('saving% s'%image_title) db.commit () # range range 1

Tags: Websites individuals developers emoticons learning effects renderings more cursors help utility next code portals keywords keywords slogans characters strings efficiency Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Linux vpn MariaDB