首页   注册   登录
 jnuc093 最近的时间轴更新

jnuc093

V2EX 第 74898 号会员,加入于 2014-09-24 10:19:59 +08:00
jnuc093 最近回复了
下面要改成递归方法和叫错
修改好了

with open("tmp/ztree.csv", "a") as csvfile:
writer = csv.writer(csvfile)
for num,e in enumerate(elementList,start=1):
writer.writerow([e.text])
try:
print(num)
print(e.get_attribute('innerHTML'))
e.find_element_by_class_name('center_close').click()
time.sleep(2)
#print(eparent)
#eparent.click()
except WebDriverException:
print("Element is not clickable")


print(e.text)
(v365env) ➜ music163-spiders git:(master) ✗ pip install html5lib
Collecting html5lib
Using cached https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl
Collecting six>=1.9 (from html5lib)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting webencodings (from html5lib)
Using cached https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Installing collected packages: six, webencodings, html5lib
Successfully installed html5lib-1.0.1 six-1.11.0 webencodings-0.5.1


(v365env) ➜ music163-spiders git:(master) ✗ pyenv versions
system
3.6.5
3.6.5/envs/v365env
* v365env (set by PYENV_VERSION environment variable)
'''
➜ ~ pyenv versions
* system (set by /Users/qk/.pyenv/version)
3.6.5
3.6.5/envs/v365env
v365env
'''
我使用的效果是这样:
➜ document git:(master) ✗ pyenv activate v365env
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(v365env) ➜ document git:(master) ✗ python
Python 3.6.5 (default, Nov 17 2018, 21:07:54)
关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2226 人在线   最高记录 4019   ·  
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.1 · 9ms · UTC 15:25 · PVG 23:25 · LAX 07:25 · JFK 10:25
♥ Do have faith in what you're doing.
沪ICP备16043287号-1