Selenium Webdriver弹出框 微博分享的内容控制与结果生成

browser.window_handles

 

for i in ugc_url_l:
js = 'window.location.href="{}"'.format(i)
browser.execute_script(js)
time.sleep(random.randint(20, 60))

browser.find_element_by_xpath('/html/body/div/div[2]/div[1]/div/div[2]/span').click()
time.sleep(random.randint(20, 60))

h0, h1 = browser.window_handles
browser.switch_to.window(h1)
weibo_start_str = 'DOAEZ朵韵诗招商网http://www.icarei.cn/'
wb_txt = browser.find_element_by_id('weiboPublisher').text.replace('【(分享来自 @今日头条)', weibo_start_str)
js = 'document.getElementById("weiboPublisher").value="{}";document.getElementById("shareIt").click();'.format(
wb_txt);
browser.execute_script(js);
time.sleep(random.randint(40, 100))
browser.close()
browser.switch_to.window(h0)
time.sleep(random.randint(40, 100))







posted @   papering  阅读(273)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2017-01-26 UTF-8
2017-01-26 CSS
点击右上角即可分享
微信分享提示