用python的selenium写爬虫通过绝对坐标点击,坐标的获取方法
注:
适用于谷歌浏览器浏览器;
其中css选择器为目标区域的css表达式;
网页F12打开源代码,在console窗口输入
#
Left计算X坐标
document.querySelectorAll('css选择器')[0].getBoundingClientRect().left + document.documentElement.scrollLeft
#Top计算Y坐标
document.querySelectorAll('css选择器')[0].getBoundingClientRect().top + document.documentElement.scrollTop
若该css区域过大,需计算其区域大小
#width计算区域宽度
document.querySelectorAll('css选择器')[0].getBoundingClientRect().width
#height计算区域高度
document.querySelectorAll('css选择器')[0].getBoundingClientRect().height
坐标原点为网页视图左上角顶点,可通过计算后再去点击