需要几个模块,xlrd,xlwt,xlutils,selenium,都可以用pip安装。
打开命令提示行,pip install xlrd
其他类似。
如果pip命令失败,则需要右键,我的电脑,属性,高级系统设置,环境变量,path变量,在%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;D:\Program Files\AMD\ATI.ACE\Core-Static;后面添加
D:\Program Files\Python37\Scripts;。
需提前准备好excel表格,里面填好用户名,帐号,密码,说说内容。如果只是自己的一个人的帐号,则可以在程序里直接写入。
另,由于要驱动chrome浏览器,需要一个驱动,地址https://sites.google.com/a/chromium.org/chromedriver/downloads
提示:chrome浏览器打开网页后,右键,检查,寻找关键词,点击一个剪头的地方也可以直接定位按钮之类的东西。寻找类似id的东西。
另,如果只是一个帐号的登录,则简单的多,只需要直接username和password赋值即可,不需要读取excel的内容。xlrd,xlwt,xlutils都用不到。
import time
import xlrd
import xlwt
import time
from xlutils.copy import copy # as cp
from selenium import webdriver