自动登录所有账号(再也不怕忘记密码)
定时抓取竞品数据(运营人狂喜)
秒杀限量商品(手速不够代码来凑)
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysdriver = webdriver.Chrome() # 需下载对应浏览器驱动driver.get("https://www.google.com")search_box = driver.find_element(By.NAME, "q")search_box.send_keys("Python自动化" + Keys.RETURN)print(driver.title)driver.quit()
import requestsfrom bs4 import BeautifulSoupurl = "https://example.com"response = requests.get(url)soup = BeautifulSoup(response.text, 'html.parser')titles = [h1.text for h1 in soup.find_all('h1')] # 提取所有<h1>标签print(titles)
3秒合并100个表格(告别复制粘贴)
自动清洗混乱数据(错误值一键修复)
每天9点准时发送日报(让邮件自己跑)
import pandas as pd# 读取Excel并处理df = pd.read_excel("data.xlsx")df['New_Column'] = df['Old_Column'] * 2 # 新增列df.to_csv("processed_data.csv", index=False) # 保存为CSV
import osfolder = "./files"for i, filename in enumerate(os.listdir(folder)): new_name = f"document_{i}.txt" os.rename(os.path.join(folder, filename), os.path.join(folder, new_name))
自动整理桌面文件(强迫症福音)
批量处理图片/视频(自媒体人必备)
软件自动操作(连PS都能自己P图)
import pyautoguipyautogui.click(100, 100) # 点击屏幕坐标(100,100)pyautogui.typewrite("Hello, World!", interval=0.1) # 模拟打字pyautogui.hotkey('ctrl', 'c') # 组合键
from pywinauto import Applicationapp = Application().start("notepad.exe") # 打开记事本app.Notepad.edit.type_keys("Automation Test") # 输入文本app.Notepad.menu_select("文件->保存") # 点击菜单