In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "Python how to achieve computer wallpaper collection and rotation effect", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Python how to achieve computer wallpaper collection and rotation effect" bar!
Bright spot
1. Systematic analysis page
2. Multi-page data analysis
3. Save massive picture data
Environment
Python 3.8
Pycharm 2021.2
Requests pip install requests
Parsel pip install parsel
Module installation issu
If you install a python third-party module:
Win + R enter cmd Click OK, enter the installation command pip install module name (pip install requests) enter
Click Terminal (terminal) in pycharm to enter the installation command
How to configure the python interpreter in pycharm?
Select file (File) > setting (Settings) > Project (Project) > python interpreter (python interpreter)
Click on the gear and select add
Add python installation path
How does pycharm install plug-ins?
Select file (File) > setting (Settings) > Plugins (plug-in)
Click Marketplace to enter the name of the plug-in you want to install, such as: translation plug-in input translation / Chinese plug-in input Chinese
Select the appropriate plug-in and click install.
After successful installation, the option to restart pycharm will pop up. Click OK, and the restart will take effect.
Python: programming language ()
Using computer language (0 1): a language used to interact with computers
Translate English words into 0 or 1 python 3.8
Implement a series of operations
Code Editor: pycharm 2021.2
Python: tool
Built in module
Third-party module
Python case (collect wallpapers on the other side)
Go to the picture list page and click to go to the picture details page.
Click the picture in the picture details page
Go to the big picture page and get the picture.
Code implementation
Access when the picture list page (send request)
Get data
Parsing data
Send a request (visit the website)
Collect wallpaper # Import tool import requestsimport parselfor page in range (2,16): url = f 'http://www.netbian.com/meinv/index_{page}.htm' # 1. Send request response = requests.get (url) # garbled response.encoding = 'gbk' # 2. Get data html_data = response.text # 3. Parse the data picture link to get the extracted selector = parsel.Selector (html_data) img_list = selector.css ('.list img::attr (src)'). Getall () for img_url in img_list: # small picture > > large picture img_url = img_url.replace ('small' '') # http://img.netbian.com/file/2022/0416/small0003229mRl41650038602.jpg img_url = img_url [:-14] + '.jpg' # extract the picture name img_name = img_url.split ('/') [- 1] # directly get the binary data of the picture img_data = requests.get (img_url) .content Print (img_name) # Save data with open (f'img/ {img_name}' Mode='wb') as f: f.write (img_data) automatically change wallpaper import win32apiimport win32conimport win32guiimport osimport timedef Windows_img (paperPath): k=win32api.RegOpenKeyEx (win32con.HKEY_CURRENT_USER, "Control panel\\ Desktop", 0) # write attribute values win32api.RegSetValueEx (k, "wapaperStyle", 0win32con.REGREGUSZ) in the registry "2") # 0 represents the center of the desktop, 2 represents the stretched desktop win32api.RegSetValueEx (k, "Tilewallpaper", 0meme win32con.REGREGROSZ, "0") win32gui.SystemParametersInfo (win32con.SPI_SETDESKWALLPAPER,paperPath) Win32con.SPIF_SENDWININICHANGE) # Refresh Desktop def changeWallpaper (): "" folder / folder / picture "" # path=input ('Please enter the file path:') path= r "C:\ 02-instructor folder\ monthly Open course\ topic\ wallhaven\ img" L2=os.listdir (path=path) # get the wallpaper folder under the file path List type item0 print (L2) # wallpaper folder url_list = [] for L2 in L2: detail_path = path +'\'+ L2 L3 = os.listdir (detail_path) # get the pictures under the wallpaper folder path List type for L3 in L3: url_list.append (detail_path +'\\'+ L3) print (url_list) while True: Windows_img (url_ list [I]) print ('{} '.format (url_ list [I]) time.sleep (2) # sets the wallpaper replacement interval, here is 10 seconds Set the number of seconds according to the user's own needs I + = 1 if I = = len (url_list): # if it is the last picture Then go back to the first I = 0def changeWallpaper_2 (): "" folder / picture "" path= input ('Please enter the file path:') # path= r "C:\ 02-instructor folder\ monthly Open course\ topic\ enter Desktop Wallpaper\ img" L2=os.listdir (path=path) # get the picture under the file path List type item0 print (L2) while True: Windows_img (path+'\ {} '.format (L2 [I]) print (path+'\ {}' .format (L2 [I])) time.sleep (10) # set the wallpaper replacement interval, here is 10 seconds, set the number of seconds according to the user's own needs, I + = 1 if i==len (L2): # if it is the last picture Then go back to the first piece of i=0if _ _ name__ = ='_ main__': changeWallpaper_2 () Thank you for your reading, which is the content of "how Python achieves the effect of computer wallpaper collection and rotation". After the study of this article, I believe you have a deeper understanding of how to achieve the effect of computer wallpaper collection and rotation of Python. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.