[python自动化]selenium实现超星某某通自动评论

[python自动化]selenium实现超星某某通自动评论,第1张

概述目录思路代码封装效果思路使用selenium提供的函数实现标签的定位与页面的切换。编写js代码找上者无法定位的标签(jQuery简单应用)selenium执行js代码代码封装fromseleniumimportwebdriverfromtimeimportsleepclassAutoComment:js="letsubmitEle=

目录思路代码封装效果

思路使用selenium提供的函数实现标签的定位与页面的切换。编写Js代码找上者无法定位的标签(jquery简单应用)selenium执行Js代码代码封装
from selenium import webdriverfrom time import sleepclass autoComment:    Js = "let submitEle=$('.qdBtn');" \         "submitEle.click();"    def __init__(self, phone, password):        self.phone = phone        self.password = password    def start(self, path, name):        """        开始评论        :param name: 课程名        :param path: 本地Edge浏览器驱动的路径        :return:        """        b = webdriver.Edge(path)        b.get('https://passport2.chaoxing.com/login?fID=&newversion=true&refer=http%3A%2F%2Fi.chaoxing.com')        b.maximize_window()        b.find_element_by_ID('phone').send_keys(self.phone)        b.find_element_by_ID('pwd').send_keys(self.password)        b.find_element_by_ID('loginBtn').click()        sleep(2)        b.switch_to.frame('frame_content')        b.find_element_by_link_text(name).click()        windows = b.window_handles        b.switch_to.window(windows[-1])        b.find_element_by_link_text('讨论').click()        for i in range(50):            Title = b.find_element_by_ID('c_Title')            Title.click()            Title.send_keys(i)            b.execute_script(self.Js)            b.switch_to.alert.accept()            sleep(2)
效果

总结

以上是内存溢出为你收集整理的[python自动化]selenium实现超星某某通自动评论全部内容,希望文章能够帮你解决[python自动化]selenium实现超星某某通自动评论所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1184645.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存