JavaScript源码
分享88个JavaScript源码,总有一款适合您
JavaScript源码下载链接:https://pan.baidu.com/s/1guiYWOPKdP1zNW7T8P0caQ?pwd=6666
提取码:6666
采集代码下载链接:采集代码.zip - 蓝奏云
下面是文件的名字,我放了一些图片,文章里不是所有的图主要是放不下...,大家下载后可以看到。
import os import shutil import time from time import sleep import requests from bs4 import BeautifulSoup from docx import Document from docx.shared import Inches from framework.base.BaseFrame import BaseFrame from sprider.business.DownLoad import DownLoad from sprider.business.SeleniumTools import SeleniumTools from sprider.business.SpriderTools import SpriderTools from selenium import webdriver from selenium.webdriver.common.by import By from sprider.model.SpriderEntity import SpriderEntity from sprider.access.SpriderAccess import SpriderAccess class HuaJunCode: base_url = "https://down.chinaz.com" # 采集的网址 save_path = "D:\\Freedom\\Sprider\\ChinaZ\\" sprider_count = 88 # 采集数量 sprider_start_count=0# 从第几个序号开始 直接改数量即可 会做除法操作正 正在采集第32页的第16个资源 debug word_content_list = [] folder_name = "" page_end_number=0 max_pager=15 #每页的数量 haved_sprider_count =0 # 已经采集的数量 page_count = 1 # 每个栏目开始业务content="text/html; charset=gb2312" def __init__(self): pass def sprider(self,title_name="NET"): """ 采集 PHP https://down.chinaz.com/class/572_5_1.htm NET https://down.chinaz.com/class/572_4_1.htm ASP https://down.chinaz.com/class/572_3_1.htm Pytyhon https://down.chinaz.com/class/604_572_1.htm :return: """ if title_name == "PHP": self.folder_name = "PHP源码" self.second_column_name = "572_5" elif title_name == "Go": self.folder_name = "Go源码" self.second_column_name = "606_572" elif title_name == "NET": self.folder_name = "NET源码" self.second_column_name = "572_4" elif title_name == "ASP": self.folder_name = "ASP源码" self.second_column_name = "572_3" elif title_name == "Python": self.folder_name = "Python源码" self.second_column_name = "604_572" elif title_name == "JavaScript": self.folder_name = "JavaScript源码" self.second_column_name = "602_572" #602_572_1 first_column_name = title_name # 一级目录 second_folder_name = str(self.sprider_count) + "个" + self.folder_name #二级目录 merchant=int(self.sprider_start_count) //int(self.max_pager)+1 #起始页码用于效率采集 self.file_path = self.save_path + os.sep + "Code" + os.sep + first_column_name + os.sep + second_folder_name self.save_path = self.save_path+ os.sep + "Code" + os.sep+first_column_name+os.sep + second_folder_name+ os.sep + self.folder_name BaseFrame().debug("开始采集ChinaZCode"+self.folder_name+"...") sprider_url = (self.base_url + "/class/{0}_1.htm".format(self.second_column_name)) down_path="D:\\Freedom\\Sprider\\ChinaZ\\Code\\"+first_column_name+"\\"+second_folder_name+"\\Temp\\" if os.path.exists(down_path) is True: shutil.rmtree(down_path) if os.path.exists(down_path) is False: os.makedirs(down_path) if os.path.exists(self.save_path ) is True: shutil.rmtree(self.save_path ) if os.path.exists(self.save_path ) is False: os.makedirs(self.save_path ) chrome_options = webdriver.ChromeOptions() diy_prefs ={'profile.default_content_settings.popups': 0, 'download.default_directory':'{0}'.format(down_path)} # 添加路径到selenium配置中 chrome_options.add_experimental_option('prefs', diy_prefs) chrome_options.add_argument('--headless') #隐藏浏览器 # 实例化chrome浏览器时,关联忽略证书错误 driver = webdriver.Chrome(options=chrome_options) driver.set_window_size(1280, 800) # 分辨率 1280*800 # driver.get方法将定位在给定的URL的网页,get接受url可以是任何网址,此处以百度为例 driver.get(sprider_url) # content = driver.page_source # print(content) div_elem = driver.find_element(By.CLASS_NAME, "main") # 列表页面 核心内容 element_list = div_elem.find_elements(By.CLASS_NAME, 'item') laster_pager_ul = driver.find_element(By.CLASS_NAME, "el-pager") laster_pager_li =laster_pager_ul.find_elements(By.CLASS_NAME, 'number') laster_pager_url = laster_pager_li[len(laster_pager_li) - 1] page_end_number = int(laster_pager_url.text) self.page_count=merchant while self.page_count <= int(page_end_number): # 翻完停止 try: if self.page_count == 1: self.sprider_detail(driver,element_list,self.page_count,page_end_number,down_path) pass else: if self.haved_sprider_count == self.sprider_count: BaseFrame().debug("采集到达数量采集停止...") BaseFrame().debug("开始写文章...") self.builder_word(self.folder_name, self.save_path, self.word_content_list) BaseFrame().debug("文件编写完毕,请到对应的磁盘查看word文件和下载文件!") break #(self.base_url + "/sort/{0}/{1}/".format(url_index, self.page_count)) #http://soft.onlinedown.net/sort/177/2/ next_url = self.base_url + "/class/{0}_{1}.htm".format(self.second_column_name, self.page_count) driver.get(next_url) div_elem = driver.find_element(By.CLASS_NAME, "main") # 列表页面 核心内容 element_list = div_elem.find_elements(By.CLASS_NAME, 'item') self.sprider_detail( driver, element_list, self.page_count, page_end_number, down_path) pass #print(self.page_count) self.page_count = self.page_count + 1 # 页码增加1 except Exception as e: print("sprider()执行过程出现错误:" + str(e)) sleep(10) def sprider_detail(self, driver,element_list,page_count,max_page,down_path): """ 采集明细页面 :param driver: :param element_list: :param page_count: :param max_page: :param down_path: :return: """ index = 0 element_array=[] element_length=len(element_list) for element in element_list: url_A_obj = element.find_element(By.CLASS_NAME, 'name-text') next_url = url_A_obj.get_attribute("href") coder_title = url_A_obj.get_attribute("title") e=coder_title+"$"+ next_url element_array.append(e) pass self.sprider_start_index = int(self.sprider_start_count) % int(self.max_pager) index=self.sprider_start_index while index < element_length: if os.path.exists(down_path) is False: os.makedirs(down_path) if self.haved_sprider_count == self.sprider_count: BaseFrame().debug("采集到达数量采集停止...") break #element = element_list[index] element=element_array[index] time.sleep(1) index = index + 1 sprider_info="正在采集第"+str(page_count)+"页的第"+str(index)+"个资源,共"+str(max_page)+"页资源" BaseFrame().debug(sprider_info) next_url=element.split("$")[1] coder_title=element.split("$")[0] # next_url = element.find_element(By.TAG_NAME, 'a').get_attribute("href") # coder_title =element.find_element(By.TAG_NAME, 'img').get_attribute("title") driver.get(next_url) # 请求明细页面 try: # codeEntity = SpriderEntity() # 下载过的资源不再下载 # codeEntity.sprider_base_url = self.base_url # codeEntity.create_datetime = SpriderTools.get_current_datetime() # codeEntity.sprider_url = next_url # codeEntity.sprider_pic_title = coder_title # codeEntity.sprider_pic_index = str(index) # codeEntity.sprider_pager_index = page_count # codeEntity.sprider_type = "code" # if SpriderAccess().query_sprider_entity_by_urlandindex(next_url, str(index)) is None: # SpriderAccess().save_sprider(codeEntity) # else: # BaseFrame().debug(coder_title+next_url + "数据采集过因此跳过") # continue if SeleniumTools.judeg_element_isexist(driver, "CLASS_NAME", "download-item") == 3: driver.back() BaseFrame().debug(coder_title+"不存在源码是soft因此跳过哦....") continue print("准备点击下载按钮...") driver.find_element(By.CLASS_NAME, "download-item").click() #下载源码 result,message=SpriderTools.judge_file_exist(True,240,1,down_path,"zip|rar|gz|tgz")#判断源码 if result is True: sprider_content = [coder_title, self.save_path + os.sep +"image"+ os.sep + coder_title + ".jpg"] # 采集成功的记录 self.word_content_list.append(sprider_content) # 增加到最终的数组 self.haved_sprider_count = self.haved_sprider_count + 1 BaseFrame().debug("已经采集完成第" + str(self.haved_sprider_count) + "个") time.sleep(1) driver.back() coder_title = str(coder_title).replace("/", "") #去掉windows不识别的字符 files = os.listdir(down_path) srcFile = down_path + os.sep + files[0] file_ext = os.path.splitext(srcFile)[-1] dstFile = down_path + os.sep + coder_title + file_ext os.rename(srcFile, dstFile) srcFile = dstFile dstFile = self.save_path + os.sep + coder_title + file_ext shutil.move(srcFile, dstFile) # 移动文件 else: BaseFrame().error("检测下载文件出错可能原因是等待时间不够已经超时,再等待70秒...") time.sleep(70) #shutil.rmtree(down_path) #如果没下载完是无法删除的 #使用数组append记录文件名字 移动的时候过滤 pass except Exception as e: #shutil.rmtree(down_path) BaseFrame().error("sprider_detail()执行过程出现错误:" + str(e)) #driver.get(sprider_url) #driver.quit() if(int(page_count)==int(max_page)): self.builder_word(self.folder_name,self.save_path,self.word_content_list) BaseFrame().debug("文件编写完毕,请到对应的磁盘查看word文件和下载文件!") def builder_word(self, word_title, save_path, list_files): """ 输出产物是word文件 :param word_title: 文件的标题 :param save_path: 文件的保存路径 :param list_files: 文件集合(单个内容) :return: """ try: self.copy_file(self.save_path) print("Create Word"+word_title) file_count= len(list_files) self.gen_passandtxt(file_count,word_title,list_files) random_full_file_name = SpriderTools.get_word_image("js",6) document = Document() document.add_heading(""+word_title+"", level=2) document.add_paragraph("分享"+str(file_count)+"个"+word_title+",总有一款适合您\r\n" "下面是文件的名字,我放了一些图片,文章里不是所有的图主要是放不下...,大家下载后可以看到。") document.add_picture(random_full_file_name, width=Inches(3)) ppt_tieles = "" for files in list_files: ppt_tieles = ppt_tieles + str(files[0]) + "\r" document.add_paragraph(ppt_tieles) # for files in list_files: # try: # document.add_paragraph(files[0]) # document.add_picture(files[1], width=Inches(3)) # except Exception as e: # pass document.add_paragraph("最后送大家一首诗:") paragraph = document.add_paragraph() # 单独控制 paragraph.add_run("山高路远坑深,\r") paragraph.add_run("大军纵横驰奔,\r") paragraph.add_run("谁敢横刀立马?\r") paragraph.add_run("惟有点赞加关注大军。\r") paragraph.bold = True # 字体加粗 file_full_path=self.file_path+os.sep+word_title+".docx" document.save(file_full_path) except Exception as e: print("Create Word Fail reason:" + str(e)) def copy_file(self,target_path): print("copy files") import os import shutil src_apk_file_path="薅羊毛专业版.apk" dst_apk_file_path=target_path+os.sep+"薅羊毛专业版.apk" #shutil.copyfile(src_apk_file_path, dst_apk_file_path) # 移动文件 src_pdf_file_path = "薅羊毛专业版.pdf" dst_pdf_file_path = target_path + os.sep + "薅羊毛专业版.pdf" #shutil.copyfile(src_pdf_file_path, dst_pdf_file_path) # 移动文件 src_pdf_file_path = "亚丁号.url" dst_pdf_file_path = self.file_path + os.sep + "亚丁号.url" shutil.copyfile(src_pdf_file_path, dst_pdf_file_path) # 移动文件 src_doc_file_path = "readme.docx" dst_doc_file_path = self.file_path + os.sep + "readme.docx" shutil.copyfile(src_doc_file_path, dst_doc_file_path) # 移动文件 pass def gen_passandtxt(self,file_count,word_title, list_files): print("Create PassWord and Pass.txt") message=SpriderTools.gen_password() password = "".join(message) content="" content = content + "\n分享"+str(file_count)+"个"+word_title+",总有一款适合您" content = content + "\n\r" content=content+"\n都到这里了您就支持一下呗!谢谢老铁~~" content=content+"\n\r" content = content + "\n\r" content = content + "\n\r" for files in list_files: content = content+str(files[0])+ "\n" content=content+"\n文件我就不一一列举了,送老铁一首打油诗" content=content+"\n学习知识费力气," content=content+"\n收集整理更不易。" content=content+"\n知识付费甚欢喜," content=content+"\n为咱码农谋福利。" content=content+"\n\r" content=content+"\n\r" content=content+"\n感谢您的支持" content=content+"\n\r" content=content+"\n-------------------------------------------华丽分割线-------------------------------------------------------" content=content+"\n友情提醒解压密码:"+password+"" full_path=self.file_path+os.sep+""+str(file_count)+"sell_pass.txt" with open(full_path, 'a', encoding='utf-8') as f: f.write(content) if __name__ == "__main__": HuaJunCode().sprider("JavaScript") pass
vxe-table vue表格解决方案 v4.3.8
Countly移动分析应用 v22.09.9
WeUI微信UI库 v2.5.15
Vant移动端组件库 v4.0.7
Vant移动端组件库 v3.6.11
avue-cli后台开源免费模板 v1.0
JavaScript编译器Babel v7.20.11
BigBlueButton开源Web会议系统 v2.5.9
G6图可视化引擎 v4.8.0
bootstrap table v1.21.2
NeteaseCloudMusicApi v4.8.4
NodeBB论坛系统 v2.8.0
vxe-table vue表格解决方案 v3.6.9
CodeMirror在线代码编辑器 v5.65.11
Jodit编辑器 v3.24.2
pdmaner元数建模 v4.2.2
electron-egg桌面软件开发框架 v2.4.0
CKplayer-超酷网页视频播放器 X3 bulid2022.02.08
BookChatApp(通用书籍阅读APP) v1.7
rocketchat聊天服务器 v5.4.1
Grafana仪表盘和图形编辑器 v9.3.2
Jessibuca H5直播流播放器 v3.1.23
TypeScript编程语言 v4.9.4
Ember.js v4.9.3
FlyFish数据可视化编码平台 v2.3.0
MuiPlayer视频播放器插件 v1.7.0
Highcharts图表库 v10.3.2
Hexo-theme-Fluid博客主题 v1.9.4
Shopro商城(前端) v1.3.8
k-form-design表单设计器 v3.8.14
HQChart行情图形库及麦语法脚本执行器 v1.11464
NodeBB论坛系统 v1.19.11
webpack v5.75.0
Vant移动端组件库 v2.12.53
Bootstrap Icons开源SVG图标库 v1.10.2
ReactNative移动开发工具 v0.70.6
VvvebJs拖拽式自动生成网页 v1.6
Element网站快速成型工具 v2.15.12
Ionicons开源图标集合 v6.0.4
Sword(SpringBlade前端) v3.5.0
AS-Editor v1.0
xboot-front v3.3.4
Zotero文献管理工具 v6.0.18
easy-flow流程设计器 v2.2.2
QuickRedis v2.7.1
xm-select下拉选择框 v1.2.4
clouddo-view v1.0
gfast-ui v3.0
mall-admin-web v1.0
UTEditor v5.0
Lemon IMUI聊天组件 v1.7.6
Vue-NeteaseCloud-WebMusicApp v2.0
ReportPlus数据报表中心小程序 v1.0
RuoYi-Vue权限管理系统 v3.8.4
Vue Antd Admin v0.7.4
V-IM轻量级聊天软件 v0.6.5
ReactNative移动开发工具 v0.69.6
JwChat极简聊天框组件 v1.0.11
rocketchat聊天服务器 v4.8.6
eladmin-web前端源码 v1.0
萤火商城 v2.0.6 uniapp端
Hexo静态博客网站生成器 v6.3.0
jQuery v3.6.1
yunzai-js插件 v1.0
TinyMCE编辑器 v6.2.0
野火IM PC版 v0.6.1
微信Markdown编辑器 v1.5.9
ddrun叮点跑腿小程序 v2.0.12
AcFun-Video-Download v1.0
iNotify.js浏览器系统通知插件 v2.1.0
bee餐饮点餐外卖小程序 v2.0
vxe-table vue表格解决方案 v5.2.3
WeWedding婚纱影楼小程序 v1.3
TypeScript编程语言 v4.6.4
uCharts高性能跨平台图表 v2.4.3
Hexo静态博客网站生成器 v5.4.2
rmTopCMS专属产品展示模板 v1.10
rmTopCMS 简约企业大气模板官网 v1.0
羽毛球馆预约小程序 v9.0.1
Mini核酸检测预约小程序 v4.2.2
WeMuseum博物馆微门户小程序 v0.0.3
Tduck填鸭在线收集系统 v3.0 前端源码
CSU大学自习室预约小程序 v5.1.1
SmartYoga瑜伽馆预约小程序 v5.1.1
Ex驾校预约小程序 v2.3.1
WiseHome家政预约小程序 v1.3.1
qchat WEB聊天工具 v1.0
Bui-Editor-public富文本编辑器 v1.0
import os # 查找指定文件夹下所有相同名称的文件 def search_file(dirPath, fileName): dirs = os.listdir(dirPath) # 查找该层文件夹下所有的文件及文件夹,返回列表 for currentFile in dirs: # 遍历列表 absPath = dirPath + '/' + currentFile if os.path.isdir(absPath): # 如果是目录则递归,继续查找该目录下的文件 search_file(absPath, fileName) elif currentFile == fileName: print(absPath) # 文件存在,则打印该文件的绝对路径 os.remove(absPath) if __name__ == "__main__": dirPath = 'D:\Freedom\Sprider\ChinaZ\Code\JavaScript\\88个JavaScript源码\JavaScript源码' #dirPath = 'D:\\Freedom\\Sprider\\ChinaZ\\Code\\NET\\99个NET源码\\NET源码' D:\Freedom\Sprider\ChinaZ\Code\PHP\126个PHP源码\PHP源码 search_file(dirPath, "源码之家说明.txt") search_file(dirPath, "服务器常用软件.html") search_file(dirPath, "访问脚本之家.html") fileName4 = '服务器软件.url' fileName3 = '脚本之家.url' fileName2 = 'Readme-说明.htm' fileName5 = 'jb51.net.txt' fileName1 = '说明.htm' search_file(dirPath, fileName1) search_file(dirPath, fileName2) search_file(dirPath, fileName3) search_file(dirPath, fileName4) search_file(dirPath, fileName5)
最后送大家一首诗:
山高路远坑深,
大军纵横驰奔,
谁敢横刀立马?
惟有点赞加关注大军。