最出圈的编程语言Python爬虫初体验
上次使用了Python体验了爬虫功能,相对于其他语言还是十分简单方便易上手的。
并且了解了Python的发展方向主要分为以下几点:
- Web开发
- 网络爬虫
- 数据分析
- 人工智能和机器学习
- 自动化测试
- 自动化运维
- …
今天我们就来体验一下Python的自动化功能~ 并且来实现一个自动给指定文章点赞功能。
PyAutoGUI
正如前面所了解的,Python拥有很多强大的库,我们这次使用的就是PyAutoGUI。
首先我们进入它的官网pyautogui.readthedocs.io/en/latest/
pyautogui.readthedocs.io/en/latest/i… 同样的,如果我们要使用它,首先要进行安装。我们点击它的Installtion页面,可以看到介绍了许多系统如何进行安装。
pip install pyautogui
安装成功后我们来学习如何使用吧。
使用
我们查看官网,可以发现主要是由四个功能:
- 鼠标控制
- 键盘控制
- 消息窗口
- 屏幕截图
我们通过其提供的Examples来感受一下
import pyautogui
# get screen width and screen height
screenWidth, screenHeight = pyautogui.size()
print(screenWidth, screenHeight)
# get current MouseX and MouseY
currentMouseX, currentMouseY = pyautogui.position()
print(currentMouseX, currentMouseY)
# move the mouse to XY coordinates
pyautogui.moveTo(27, 104)
# mouse click
pyautogui.click()
# move the mouse to XY coordinates and click it
pyautogui.click(27, 104)
# move the mouse 500 px the right of its current position
pyautogui.move(500, 0)
# doub