Message: unknown error: Element is not clickable at point
Message: unknown error: Element is not clickable at point
google chrome - Debugging "Element is not clickable at point" error - Stack Overflow https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error
from selenium import webdriver
import os
import time
import pymysql
from bs4 import BeautifulSoup
import requests
import threading
from selenium.webdriver.common.keys import Keys h, pt, u, p, db = 'localhost', 3306, 'root', '', 'qqzone' def mysql_fetch(sql, res_type='tuple'):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8mb4')
except Exception as e:
print(e)
return ()
if res_type == 'dic':
cursor = conn.cursor(pymysql.cursors.DictCursor)
else:
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
r = cursor.fetchall()
cursor.close()
conn.close()
return r def mysql_write(sql):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8mb4')
except Exception as e:
print(e)
return 1
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
return 0 # D:\pyaction\toutiao_team_win img_dir = 'C:/Users/Administrator/Desktop/1/toutiao_team/dl_img/'
img_dir = 'D:/pyaction/toutiao_team_win/dl_img/' import random def spider_webimg_dl_return_local_img_path(img_dir, img_url, media_type='img',
local_default='default.DONOT_REMOVE.png'):
r = '%s%s' % (img_dir, local_default) if media_type == 'img':
try:
req = requests.get(img_url)
time.sleep(3)
if req.status_code != 200:
print('-!=200')
return r
time.sleep(30)
print(img_url)
bytes = req._content
# r = '%s%s%s%s%s' % (
# img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
# img_url.split('!/c')[0].split('/')[-1].replace('*', '_'), '.png')
# print(r) r = '%s%s%s%s%s' % (
img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
str(random.randrange(1000, 9999)), '.png')
print(r)
filter_l = ['&', '=', '?', '-']
for fi in filter_l:
r.replace(fi, '')
if bytes != 0:
with open(r, 'wb')as f:
f.write(bytes)
except Exception as e:
print(e)
elif media_type == 'mp4':
try:
time.sleep(30) print(img_url)
r = '%s%s%s%s%s' % (
img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
img_url.split('.mp4?')[0].split('/')[-1].replace('*', '_'), '.mp4')
print(r)
req = requests.get(img_url)
time.sleep(3)
if req.status_code != 200:
print('-!=200')
return ''
bytes = req._content
time.sleep(210)
if bytes != 0:
with open(r, 'wb')as f:
f.write(bytes)
except Exception as e:
r = ''
print(e) return r driver = webdriver.Chrome()
myurl = 'https://weibo.com/u/1779073702'
myurl = 'https://weibo.com/u/1779073702?is_all=1'
myurl = 'https://weibo.com/login.php'
driver.get(myurl)
# 此处需要内存和cpu空余,能够支持dom解析和处理重js页面
time.sleep(10)
driver.refresh()
time.sleep(10)
# xp = '//*[@id="pl_common_top"]/div/div/div[3]/div[2]/ul/li[3]/a'
# try:
# # 此处解决了不能点击该元素报错,第三次尝试ok
# driver.find_element_by_xpath(xp).click()
# time.sleep(40)
#
# except Exception as e:
# print(e)
# os._exit(1024) js = 'document.getElementsByClassName("username")[1].childNodes[0].value="welcome.cn";' \
'document.getElementsByClassName("password")[0].childNodes[0].value="p";' \
'document.getElementsByClassName("form_login_register")[0].childNodes[5].childNodes[0].click();'
js = 'document.getElementById("loginname").value="welcome.cn";' \
'document.getElementsByName("password")[0].value="p";' \
'document.getElementsByClassName("W_btn_a btn_32px")[0].click();'
try:
driver.execute_script(js)
time.sleep(30)
except Exception as e:
print(e)
os._exit(1024) time.sleep(random.randrange(3, 6))
for isc in range(2):
# 今日头条 非iframe 无限次
# qq空间说说 iframe 固定20条 2次报错
# memory cpu
time.sleep(1)
js = 'window.scrollTo(0,document.body.scrollHeight)'
driver.execute_script(js) while True:
sql = 'SELECT id, words,imgurls,time_site FROM qqzoneshuoshuo WHERE lefttimes_weibo>0 AND INSTR(imgurls,".mp4")=0 AND id IN ( SELECT MAX(id) FROM qqzoneshuoshuo GROUP BY id_site) ORDER BY time_script DESC,id ASC ;'
res_content = mysql_fetch(sql, 'dic')
print(res_content)
if len(res_content) == 0:
continue
comment_l_sq = 0
for i in res_content[0:]:
# id, words,imgurls,time_site
dbid, content, img_list, time_site = i['id'], i['words'], i['imgurls'], i['time_site']
if 1 > 13:
if '天' in time_site or '月' in time_site:
continue
lh = int(time.strftime("%H", time.localtime()))
if lh - int(time_site.split(':')[0]) >= 24:
continue
if '早安' in content and lh >= 11:
continue
elif '晚安' in content and lh <= 20:
continue time.sleep(10)
# because another element <div> obscures it
content = content.split('展开全文')[0].split('上传')[0].split('浏览')[0].replace('"', ' ').replace("'", ' ')
content = content.replace('"', ' ').replace("'", ' ').replace('\n', ' ')
filter_l = ['密龄素材空间', '评论'] for fi in filter_l:
content = content.replace(fi, ' ')
# js = 'document.getElementsByTagName("textarea")[0].value="{}新年快乐-密龄白藜芦醇DOAEZ朵韵诗-阿静艾卡尔@ http://www.icarei.cn期待与你携手前行!!";'.format(
# content)
# js = 'document.getElementsByTagName("textarea")[0].value="{}白藜芦醇-燕窝美妆-密龄DOAEZ朵韵诗-阿静艾卡尔@ http://www.icarei.cn期待与你携手前行!!";'.format(
# content)
js = 'document.getElementsByTagName("textarea")[0].value="{}南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ http://www.icarei.cn期待与你携手前行!!";'.format(
content)
# https://item.taobao.com/item.htm?id=567557180229
ad_url_l = ['567557180229', '565875313425', '545159271159', '546048319163'] # 补水喷雾 手链 面膜 防晒喷雾
ad_url_l = ['567557180229', '565875313425', '545159271159', '546048319163', '567693004121'] # 补水喷雾 手链 面膜 防晒喷雾
ad_this = ad_url_l[int(time.time()) % len(ad_url_l)]
ad_url = 'https://item.taobao.com/item.htm?id={}'.format(ad_this)
# js = 'document.getElementsByTagName("textarea")[0].value="{}#话题# 磁石娃娃 南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ {}!!";'.format(
# js = 'document.getElementsByTagName("textarea")[0].value="{}#doaez朵韵诗磁石娃娃燕窝润颜面膜# 磁石娃娃 南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ {}!!";'.format(
# content, ad_url)
# print(js) hot_topic_list_url = 'https://weibo.com/u/1779073702/home'
js = 'window.location.href="{}"'.format(hot_topic_list_url)
driver.execute_script(js)
time.sleep(10) time.sleep(10)
hot_url_l = [i.get_attribute('href') for i in driver.find_elements_by_css_selector('li>p>a')] try:
hot_url_l_index = random.choice([int(time.time()) % len(hot_url_l), 0, 1])
except Exception as e:
print(e)
continue js = 'window.location.href="{}"'.format(hot_url_l[hot_url_l_index])
driver.execute_script(js)
time.sleep(10)
driver.refresh()
time.sleep(random.randrange(3, 6))
# for isc in range(2):
# # 今日头条 非iframe 无限次
# # qq空间说说 iframe 固定20条 2次报错
# # memory cpu
# time.sleep(1)
# js = 'window.scrollTo(0,document.body.scrollHeight)'
# driver.execute_script(js)
# driver.refresh() # time.sleep(10)
time.sleep(15) time.sleep(30)
comment_l = driver.find_elements_by_css_selector('.WB_row_line>li:nth-child(3)>a>span>span>span')
try:
time.sleep(30)
comment_l_sq=random.choice([0,0,int(time.time())%len(comment_l)])
comment_l[comment_l_sq].click()
time.sleep(30)
comment_l_sq += 1
comment_l_sq = 0
except Exception as e:
print(e)
continue time.sleep(12)
# '.WB_publish>div>textarea'
mytopic, myname = ' #doaez朵韵诗磁石娃娃燕窝润颜面膜# ', '南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ '
mystr = '{}{}{}{}'.format(mytopic, myname, content, ad_url)
js = 'document.getElementsByTagName("textarea")[1].value="{}"'.format(mystr)
try:
# 需要键盘事件 - response
driver.find_elements_by_tag_name("textarea")[1].send_keys(Keys.SPACE)
time.sleep(2)
driver.find_elements_by_tag_name("textarea")[1].send_keys(Keys.BACK_SPACE)
driver.execute_script(js)
time.sleep(2)
except Exception as e:
print(e)
continue js = "document.getElementsByName('forward')[0].click();"
driver.execute_script(js)
time.sleep(2)
js = "document.getElementsByClassName('btn W_fr')[0].childNodes[0].click()"
driver.execute_script(js)
time.sleep(2) driver.refresh()
# # 先填充文本:动态d
# # om
#
# for iimg in range(2):
# js = 'document.getElementsByClassName("ficon_image")[0].click();'
# driver.execute_script(js)
# time.sleep(2)
# upload = driver.find_element_by_id('pic_upload').find_element_by_tag_name('input')
# img_url_list = img_list.split(',')
# try:
# # MAX=8
# for img_url in img_url_list:
# if '.gif' in img_url or 'qzonestyle' in img_url:
# continue
# local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
# local_default='default.DONOT_REMOVE.png')
# print(local_img_path)
# time.sleep(2)
# upload.send_keys(local_img_path)
# except Exception as e:
# print(e)
# try:
# js = 'document.getElementsByClassName("W_layer_close")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# driver.execute_script(js)
# time.sleep(10)
# driver.refresh()
# except:
# pass
#
# continue
#
# time.sleep(5)
# js = 'document.getElementsByClassName("W_layer_close")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# # js = 'document.getElementsByTagName("textarea")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# # js = 'document.getElementsByClassName("func")[0].childNodes[3].click();'
# driver.execute_script(js)
#
# time.sleep(10) sql = 'UPDATE qqzoneshuoshuo SET lefttimes_weibo=lefttimes_weibo-1 WHERE id={}'.format(dbid)
print(sql)
try:
mysql_write(sql)
except:
pass driver.refresh() time.sleep(random.randint(60 * 0.5, 60 * 1))
# 15min后刷新,循环存入数据,期间定时刷新,维持页面
for si in range(15):
try:
driver.refresh()
time.sleep(60)
time.sleep(random.randint(0, 10))
print(si)
except Exception as e:
print(145, e)
Message: unknown error: Element is not clickable at point的更多相关文章
- 关于执行webdriver.Chrome; 报错WebDriverException: Message: unknown error: Element is not clickable at point (1085, 103)
from selenium import webdriverfrom time import sleep dr = webdriver.Chrome() dr.get("http://pj1 ...
- python控制selenium点击登录按钮时报错 unknown error: Element is not clickable at point
利用python控制selenium进行一个网页的登录时报错: C:\Users\Desktop\selenium\chrome>python chrome.py selenium.common ...
- selenium.common.exceptions.WebDriverException: Message: unknown Error: cannot find Chrome binary
使用Chrome浏览器时,经常会遇到以下报错:浏览器没有调用起来 selenium.common.exceptions.WebDriverException: Message: unknown Err ...
- Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing 'value'
Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing ' ...
- selenium WebDriverException: Message: unknown error: DevToolsActivePort file doesnt exist
在centos中使用无头chrome报以下错误 selenium.common.exceptions.WebDriverException: Message: unknown error: DevTo ...
- WebDriverException: Message: unknown error: Chrome failed to start: crashed
the last answer WebDriverException: Message: unknown error: Chrome failed to start: crashed
- robotframework执行用例时,报错selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinl
在用robotframework编写移动端测试用例(用chrome浏览器模拟手机浏览器),执行用例时, 报错selenium.common.exceptions.WebDriverException: ...
- 不能聚焦元素问题 WebDriverException: Message: unknown error: cannot focus element
上周碰到了 Unable to locate element,即“无法定位元素”,后靠两行代码解决: wait = ui.WebDriverWait(driver,5) wait.until(lamb ...
- RF运行脚本报错:WebDriverException: Message: unknown error: call function result missing
原因:浏览器驱动与浏览器版本不对应
随机推荐
- Linux环境下验证码不显示F12报500
前言: 项目之前部署在linux系统上进行测试,今天重新部署的时候,重启了tomcat然后部署新的版本项目,结果登录页面验证码不显示,在浏览器F12页面显示的是500错误.网上查了很多方法,都没效果 ...
- 去面试Python工程师,这几个基础问题一定要能回答,Python面试题No4
今天的面试题以基础为主,去面试Python工程师,这几个基础问题不能答错 第1题:列表和元组有什么不同? 列表和元组是Python中最常用的两种数据结构,字典是第三种. 相同点: 都是序列 都可以存储 ...
- Python之粘包
Python之粘包 让我们基于tcp先制作一个远程执行命令的程序(1:执行错误命令 2:执行ls 3:执行ifconfig) 注意注意注意: res=subprocess.Popen(cmd.deco ...
- 常见算法的python实现
提到排序算法,常见的有如下几种:冒泡排序.选择排序.插入排序.快速排序.堆排序.归并排序.希尔排序:查找算法最常见二分查找.这些算法的时间复杂度如下: 算法名称 时间复杂度(一般情况) 冒泡排序 O( ...
- Quartz --quartz.properties
quartz.properties 如果项目中没有该配置文件,则会去jar包中读取自带配置文件 默认的配置如下 # Default Properties file for use by StdSche ...
- android 的Manifest对图标的影响
转自 http://blog.csdn.net/yuan1590/article/details/6700683 先看看网路上的说法: Android.intent.action.MAIN决定应用程序 ...
- android listVIew实现button按钮监听程序
1.重写simpleAdapter 方法@Override public HashMap<String,String> getItem(int position) { // TODO Au ...
- c#中的委托和事件详细学习【分6页学习】
原文发布时间为:2008-11-01 -- 来源于本人的百度文章 [由搬家工具导入] 在本文中我首先通过一个GreetingPeople的小程序向大家介绍了委托的概念、委托用来做什么,随后又引出了事件 ...
- msp430入门学习12
msp430的定时器--Timer_A(定时器A) msp430入门学习
- Linux下汇编语言学习笔记33 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...