标签:blog 调用 https rom 博客 == for erro drive
---恢复内容开始---
需要用到的工具:python(pymouse、selenium)、chrome、webdriver
使用的webdriver一定要和chrome的版本相匹配,具体的对应关系可以参考以下博客:http://blog.csdn.net/goblinintree/article/details/47335563。为了避免这个问题,最好直接使用最新的chrome和最新的webdriver。
以下代码是PyMouse的源码
# -*- coding: iso-8859-1 -*- """The goal of PyMouse is to have a cross-platform way to control the mouse. PyMouse should work on Windows, Mac and any Unix that has xlib. See http://code.google.com/p/pymouse/ for more information. """ import sys class PyMouseMeta(object): def press(self, x, y, button = 1): """Press the mouse on a givven x, y and button. Button is defined as 1 = left, 2 = right, 3 = middle.""" raise NotImplementedError def release(self, x, y, button = 1): """Release the mouse on a givven x, y and button. Button is defined as 1 = left, 2 = right, 3 = middle.""" raise NotImplementedError def click(self, x, y, button = 1): """Click the mouse on a givven x, y and button. Button is defined as 1 = left, 2 = right, 3 = middle.""" self.press(x, y, button) self.release(x, y, button) def move(self, x, y): """Move the mouse to a givven x and y""" raise NotImplementedError def position(self): """Get the current mouse position in pixels. Returns a tuple of 2 integers""" raise NotImplementedError def screen_size(self): """Get the current screen size in pixels. Returns a tuple of 2 integers""" raise NotImplementedError if sys.platform.startswith(‘java‘): from java_ import PyMouse elif sys.platform == ‘darwin‘: from mac import PyMouse elif sys.platform == ‘win32‘: from windows import PyMouse else: from unix import PyMouse
由于是windows系统,所以pymouse需要调用windows的win32,否则无法正常使用。
必须要安装win32相关的控件,对应的网址是https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/。请务必选择正确的版本,我的这部分代码使用的是python2.7+64位系统,所以选择的是pywin32-221.win-amd64-py2.7.exe。
完成以上部分的内容之后正式进入到selenium+chrome+python+chrome的爬虫。
标签:blog 调用 https rom 博客 == for erro drive
原文地址:http://www.cnblogs.com/Mr24/p/6819802.html