bright spot
1. Systematic analysis page
2、Multi-page data parsing
3、Massive image data preservation
matrix
python 3.8
pycharm 2021.2
requests pip install requests
parsel pip install parsel
Module installation issues
If installing python third-party modules.
win + R type cmd and click OK, type the install command pip install module name (pip install requests) Enter
In pycharm, click Terminal and enter the install command.
How to configure python interpreter inside pycharm?
select file >>> setting >>> Project >>> python interpreter
Click on the gear, select add
Add the python installation path
How does pycharm install plugins?
Select file >>> setting >>> Plugins
Click Marketplace and enter the name of the plugin you want to install, e.g.: translation plugin, enter translation / Chinese plugin, enter Chinese.
Select the appropriate plug-in and click install.
After the installation is successful, there is an option to restart pycharm. Click OK, and the restart will take effect.
Python: Programming Language()
Computer language (0 1): Language used to interact with computers.
Translation English words into 0 or 1 python 3.8
Implementation of a series of operations
Code editor: pycharm 2021.2
Python: Tools
built-in module
Third-party modules
python case (collecting wallpaper from the other side)
Go to the picture list page and click on it. Go to the picture detail page.
Inside the image detail page Click on the image
Come to the Big Picture page and get the picture
code implementation
- Accessing the current image list page (send request)
- Getting data
- parsing data
- Send a request (to access the website)
Capture Wallpaper
# Import tool import requests import parsel for page in range(2, 16): url = f'/meinv/index_{page}.htm' # 1. Sending requests response = (url) # Messy code = 'gbk' # 2. Access to data html_data = # 3. Parsing the data. Image link acquired. Extracted. selector = (html_data) img_list = ('.list img::attr(src)').getall() for img_url in img_list: # Small pictures >>> Large pictures img_url = img_url.replace('small', '') # /file/2022/0416/ img_url = img_url[:-14] + '.jpg' # Picture name Extracted img_name = img_url.split('/')[-1] # Get image binary data directly img_data = (img_url).content print(img_name) # Data preservation with open(f'img/{img_name}', mode='wb') as f: (img_data)
Automatic wallpaper change
import win32api import win32con import win32gui import os import time def Windows_img(paperPath): k=(win32con.HKEY_CURRENT_USER,"Control panel\\Desktop",0,win32con.KEY_SET_VALUE) # Write property values in the registry (k,"wapaperStyle",0,win32con.REG_SZ,"2") # 0 for centered desktop 2 for stretched desktop (k,"Tilewallpaper",0,win32con.REG_SZ,"0") (win32con.SPI_SETDESKWALLPAPER,paperPath,win32con.SPIF_SENDWININICHANGE) # Refresh the desktop def changeWallpaper(): """Folders/Folders/Pictures""" # path=input('Please enter the path of the file:') path = r"C:\02- Instructor's Folder \Six Months Open Classes\Subjects\wallhaven\img" L2=(path=path) # Get the wallpaper folder in the file path, list type i=0 print(L2) # Wallpaper Folder url_list = [] for l2 in L2: detail_path = path + '\\' + l2 L3 = (detail_path) # Get the images in 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])) (2) # Set the wallpaper replacement interval, here for 10 seconds, according to the user's own needs to set their own seconds i += 1 if i == len(url_list): # If it's the last picture, revert to the first one # i = 0 def changeWallpaper_2(): """Folders/Pictures""" path = input('Please enter the file path:') # path = r "C:\02- Instructor's folder \ Si month open class \ subject \ return desktop wallpaper \ img" L2=(path=path) # Get images under file path, list type i=0 print(L2) while True: Windows_img(path+'\{}'.format(L2[i])) print(path+'\{}'.format(L2[i])) (10) # Set the wallpaper replacement interval, here for 10 seconds, according to the user's own needs to set their own seconds i += 1 if i==len(L2): # If it's the last picture, revert to the first one # i=0 if __name__ == '__main__': changeWallpaper_2()
This article on the Python computer wallpaper collection and rotation effect is introduced to this article, more related Python computer wallpaper content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!