当前位置: 首页 > news >正文

做网站后的收获工商年报网上怎么申报

做网站后的收获,工商年报网上怎么申报,移动互联网服务管理中心,网站cdn加速怎么入侵1.先看结构#xff1a; 声明#xff1a;我是初学#xff0c;可能有不合理的地方。 2.Base层。 我是把原来一个kimi的自动问答的代码改过来。 分析#xff1a;其实我是新手#xff0c;因为我用的浏览器是固定的#xff0c;也没有打算和别人用。所以浏览器层面年的全部写…1.先看结构 声明我是初学可能有不合理的地方。 2.Base层。 我是把原来一个kimi的自动问答的代码改过来。 分析其实我是新手因为我用的浏览器是固定的也没有打算和别人用。所以浏览器层面年的全部写死。 其他功能用到什么添什么。一步步完善。 后期我想这个这基层一直用下去。所以会一步步完善的。 base_page.py的内容如下 import timefrom selenium import webdriver from selenium.webdriver.edge.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import pyperclip import os class BasePage:def __init__(self):edge_user_data_dir rC:\Users\Administrator\AppData\Local\Microsoft\Edge\User Data\Defaultedge_options Options()edge_options.use_chromium Trueedge_options.add_argument(--disable-extensions) # 禁用浏览器扩展edge_options.add_argument(--disable-gpu) # 禁用GPU硬件加速# edge_options.add_argument(--headless) # 禁用GPU硬件加速edge_options.add_argument(f--user-data-dir{edge_user_data_dir})self.driver webdriver.Edge(optionsedge_options)self.driver.maximize_window()self.wait WebDriverWait(self.driver, 300)# self.driver driver# self.driver.implicitly_wait(10)def keep_browser_open(self):保持浏览器窗口打开等待用户操作.input(按回车键退出程序并关闭浏览器...)def js_condition(self,driver):自定义等待条件函数检查JavaScript返回值return driver.execute_script(return document.readyState) completedef open_url(self,url):self.driver.get(url)self.wait.until(self.js_condition)print(页面加载完成)return Truedef find_element(self, loc):try:return self.wait.until(EC.element_to_be_clickable(loc))except Exception as e:print(f元素未找到{loc})return Falsedef find_elements(self, loc):elements self.wait.until(EC.presence_of_all_elements_located(loc))if not elements: # 可选检查是否找到元素如果没有打印提示信息print(f没有找到匹配的元素{loc})return elementsdef click_element(self,loc):element self.find_element(loc)element.click()# self.driver.execute_script(arguments[0].click();, element)def set_text(self,loc,text):elementself.find_element(loc)element.send_keys(text)def full_path(self,filename):current_dir os.getcwd()# 确保文件名加上.txt扩展名if not filename.endswith(.txt):filename .txtfull_path os.path.join(current_dir, filename)return full_pathdef clipboard_content_to_file(self,filename):full_path self.full_path(filename)clipboard_text pyperclip.paste()with open(full_path, w, encodingutf-8) as file:file.write(clipboard_text)print(f剪贴板内容已成功写入到文件: {filename})def read_line_from_file(self,filename):full_path self.full_path(filename)numeric_line None # 初始化为None表示尚未找到符合条件的行try:with open(full_path, r, encodingutf-8) as file:for line in file:# 检查行是否以数字开头if line.strip().startswith(tuple(0123456789)):numeric_line line.rstrip(\n) # 找到第一行后移除行尾的换行符并赋值break # 终止循环except FileNotFoundError:print(f文件 {filename} 未找到。)except Exception as e:print(f读取文件时发生错误: {e})print(读取当前行,numeric_line)return numeric_linedef del_line_from_file(self, filename):full_path self.full_path(filename)numeric_line None # 初始化为None表示尚未找到符合条件的行lines_to_write_back [] # 用于存储除了被删除行外的所有行try:with open(full_path, r, encodingutf-8) as file:found False # 标记是否已找到并处理符合条件的行for line in file:if not found and line.strip().startswith(tuple(0123456789)):numeric_line line.rstrip(\n) # 找到第一行后移除行尾的换行符并赋值found True # 设置标志表示已找到并处理了符合条件的行else:lines_to_write_back.append(line) # 其他行保留准备写回文件if found: # 只有在确实找到并处理了符合条件的行后才重写文件with open(full_path, w, encodingutf-8) as file:file.writelines(lines_to_write_back)except FileNotFoundError:print(f文件 {filename} 未找到。)except Exception as e:print(f读取或修改文件时发生错误: {e})print(删除当前行, numeric_line)return numeric_linedef append_content_to_file(self,filename, content):full_path self.full_path(filename)try:with open(full_path, a, encodingutf-8) as file:file.write(content \n) # 内容后添加换行符以便于区分多条内容print(f内容已成功追加到文件: {filename})except Exception as e:print(f写入文件时发生错误: {e}) 测试用的代码都通过了。 url https://kimi.moonshot.cn/ case BasePage() case.open_url(url) #lowImage___hU90c # img_locBy.CLASS_NAME, login____RTRY # img_locBy.CLASS_NAME, lowImage___hU90c # # if case.click_element(img_loc): # print(ok) edit_loc By.XPATH,//div[data-slate-nodeelement] text你好吗 case.send_text(edit_loc,text) send_locBy.ID, send-button case.click_element(send_loc) case.keep_browser_open() 3.page层 分析因为我计划用于kimi或讯飞或其他所以在规划时。计划用主域名当成关键字。而每一部分不再分成独立模块如登录主页等。如何有跳转的话后期根据情况写在base层。 import time from class_learn.base.base_page import BasePage from selenium.webdriver.common.by import By import pyperclip import osclass KimiPage(BasePage):def __init__(self):super().__init__() # 假设BasePage也有初始化driver的逻辑则需要调用super().__init__()def web_ready(self,url,ok_loc,nok_loc):if self.open_url(url):if self.find_element(ok_loc):print(发现头像登录成功)else:self.click_element(nok_loc)def new_page(self,new_loc):self.click_element(new_loc)time.sleep(2)def get_questions(self, op_loc, op_loc1, edit_loc, keywords, send_loc, copy_loc):self.click_element(op_loc)time.sleep(1)self.click_element(op_loc1)time.sleep(1)self.set_text(edit_loc, keywords)self.click_element(send_loc)time.sleep(2)self.click_element(copy_loc)def set_text_and_send(self,edit_loc,text,send_loc):self.click_element(edit_loc)time.sleep(1)self.set_text(edit_loc,text)self.click_element(send_loc)def click_copy_and_save(self,copy_loc):passcase KimiPage() url https://kimi.moonshot.cn/ nok_locBy.CLASS_NAME, login____RTRY #未登录 ok_locBy.CLASS_NAME, lowImage___hU90c #已登录 case.web_ready(url,ok_loc,nok_loc)new_locBy.XPATH,//div[data-testidmsh-sidebar-new] case.new_page(new_loc)op_locBy.CSS_SELECTOR,.icon___zTPKp svg op_loc1By.CSS_SELECTOR,.itemContainer___eYZxh .content___EPfWU op_loc2By.CSS_SELECTOR,div:nth-child(2) .itemContainer___eYZxh .content___EPfWU edit_locBy.XPATH,//div[data-slate-nodeelement] keywords泌尿系统 send_locBy.ID, send-button copy_locBy.XPATH, //span[contains(.,复制)] # case.get_questions(op_loc,op_loc1,edit_loc,keywords,send_loc,copy_loc) # case.clipboard_content_to_file(keywords) filekeywords_ques for i in range(100):if i%100:case.new_page(new_loc)time.sleep(2)askcase.read_line_from_file(keywords)case.get_questions(op_loc,op_loc2,edit_loc,ask,send_loc,copy_loc)case.del_line_from_file(keywords)case.append_content_to_file(file, f第{i}章 {ask})case.append_content_to_file(file,pyperclip.paste()) case.keep_browser_open() 基本完成了可以自动生成100个问题自动回答自动追加到文本中自动删除已经回答过的问题。方便系统错误后接着进行每10个问题自动开始一个新的页面。 感觉比原来好用多了。清晰了看来代码要不停的写才可以。
http://www.eeditor.cn/news/119913/

相关文章:

  • 苏州市建设安全监督局网站佛山关键词搜索排名
  • 网站背景视频是怎么做的什么网站好看用h5做
  • 芒果tv网站建设的目标容桂商城网站建设
  • 院系网站建设具体要求wordpress电影分享主题
  • 网站转微信小程序中国经济网
  • 自建网站免费教程九江做网站的公司哪里好
  • 菏泽市建设局网站电话号码中学网站模板
  • 企业网站页面宽哪里设置Wordpress老是给攻击
  • 做二手的网站都有哪些网站特效 素材
  • 我为本公司想建个网站企业建站做网站
  • 自己做的网站网页滑动不内蒙古银税贷互动平台
  • 加强局网站建设报告淘宝网网页版首页登录入口
  • 男女做污视频在线观看网站wordpress likegoogle
  • 网站地图后缀jsp做网站用到什么技术
  • 湖南隆回建设局网站怎么做网站排版
  • 针对网站做的推广方案蚌埠网络科技有限公司
  • 网站保障体系建设广西省河池建设局网站
  • 嘉兴 企业网站 哪家企业网站可以做一级等保吗
  • 广东网络公司网站那个网站专门做幽默视频的
  • 汕头网站建设方案外包网站曝光率
  • 潜江网站建设兼职腾讯cdn加速优化wordpress
  • 睢县网站建设做一个网站
  • 手机建站平台哪个好全网霸屏整合营销推广
  • 手机网站搭建多少钱网站建设需要些什么
  • 网站免费正能量软件不良深汕特别合作区面积
  • 湖州建设企业网站搭建网站的方案
  • 基层建设检索网站宿松网站建设设计
  • 苏州企业网站公司都有哪些动漫制作专业专升本对应的专业
  • 杭州广众建设工程有限公司网站签约做网站模板
  • 安装wordpress主题后 显示乱码 怎么解决阳谷聊城网站优化