[Python2.7]用phantomjs和selenium遇到
2019-03-06 本文已影响0人
_小老虎_
- 错误:
File "youku_ckey.py", line 45, in youku_ckey
driver = webdriver.PhantomJS(executable_path=bce_exec_path,desired_capabilities=desired_capabilities,service_args=service_args)
File "/home/cyl/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 62, in __init__
desired_capabilities=desired_capabilities)
File "/home/cyl/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 148, in __init__
self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive)
File "/home/cyl/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 120, in __init__
port=port)
File "/home/cyl/lib/python2.7/site-packages/selenium/webdriver/common/utils.py", line 72, in find_connectable_ip
connectable = is_connectable(port, sockaddr[0])
File "/home/cyl/lib/python2.7/site-packages/selenium/webdriver/common/utils.py", line 106, in is_connectable
socket_ = socket.create_connection((host, port), 1)
File "/home/cyl/lib/python2.7/socket.py", line 554, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
TypeError: getaddrinfo() argument 1 must be string or None
- 解决:
(1). 打开/home/cyl/lib/python2.7/socket.py
(2). 如错误,定位554行发现
getaddrinfo
的方法,
打印出来这个位置的数据:
1
发现:
host有一些非string的值,所以需要修改源代码:
2
再次测试,发现成功了~
by 炎隆