遇到的问题
unknown error: call function result missing 'value'
问题:
解决方案:下载和chrome浏览器版本匹配的chromedriver
下载地址如下:
chromedriver.storage.googleapis.com/index.html
npm.taobao.org/mirrors/chr…
然后将解压的 chromedriver 移动到 /usr/local/bin
使用 chrome 的 console 检查css_selector,xpath的有效性
检查css_selector
$(css_selector) 和 ?(css_selector)
如图:前者会列出与selector匹配的所有元素,而后者则是把这些匹配到的元素组成了数组。(点击返回的每个元素,则会定位到页面中的img元素及html中的具体位置)
检查xpath
$x(path)
$x(path)返回的是一个数组,数组中即为与xpath匹配的所有元素。