当前位置:   article > 正文

分享88个C源码,总有一款适合您_c编程思想 源码

c编程思想 源码

C源码

分享88个C源码,总有一款适合您

下面是文件的名字,我放了一些图片,文章里不是所有的图主要是放不下...,大家下载后可以看到。

源码下载链接:https://pan.baidu.com/s/1TT87gt66kn5BtLqgRUTlUQ?pwd=wje5 
提取码:wje5

 

  1. import os
  2. import shutil
  3. import time
  4. from time import sleep
  5. import requests
  6. from bs4 import BeautifulSoup
  7. from docx import Document
  8. from docx.shared import Inches
  9. from framework.base.BaseFrame import BaseFrame
  10. from sprider.business.DownLoad import DownLoad
  11. from sprider.business.SeleniumTools import SeleniumTools
  12. from sprider.business.SpriderTools import SpriderTools
  13. from selenium import webdriver
  14. from selenium.webdriver.common.by import By
  15. from sprider.model.SpriderEntity import SpriderEntity
  16. from sprider.access.SpriderAccess import SpriderAccess
  17. class HuaJunCode:
  18. base_url = "https://down.chinaz.com" # 采集的网址
  19. save_path = "D:\\Freedom\\Sprider\\ChinaZ\\"
  20. sprider_count = 116 # 采集数量
  21. sprider_start_count=210# 正在采集第51页的第7个资源,共60页资源 debug
  22. word_content_list = []
  23. folder_name = ""
  24. page_end_number=0
  25. max_pager=15 #每页的数量
  26. haved_sprider_count =0 # 已经采集的数量
  27. page_count = 1 # 每个栏目开始业务content="text/html; charset=gb2312"
  28. filter_down_file=[]
  29. def __init__(self):
  30. pass
  31. def sprider(self,title_name="NET"):
  32. """
  33. 采集
  34. PHP https://down.chinaz.com/class/572_5_1.htm
  35. NET https://down.chinaz.com/class/572_4_1.htm
  36. ASP https://down.chinaz.com/class/572_3_1.htm
  37. Python https://down.chinaz.com/class/604_572_1.htm
  38. https://down.chinaz.com/class/608_572_1.htm
  39. 微信 https://down.chinaz.com/class/610_572_1.htm
  40. Ruby https://down.chinaz.com/class/622_572_1.htm
  41. NodeJs https://down.chinaz.com/class/626_572_1.htm
  42. C https://down.chinaz.com/class/594_572_1.htm
  43. :return:
  44. """
  45. if title_name == "PHP":
  46. self.folder_name = "PHP源码"
  47. self.second_column_name = "572_5"
  48. elif title_name == "Go":
  49. self.folder_name = "Go源码"
  50. self.second_column_name = "606_572"
  51. elif title_name == "NET":
  52. self.folder_name = "NET源码"
  53. self.second_column_name = "572_4"
  54. elif title_name == "ASP":
  55. self.folder_name = "ASP源码"
  56. self.second_column_name = "572_3"
  57. elif title_name == "Python":
  58. self.folder_name = "Python源码"
  59. self.second_column_name = "604_572"
  60. elif title_name == "JavaScript":
  61. self.folder_name = "JavaScript源码"
  62. self.second_column_name = "602_572"
  63. elif title_name == "Java":
  64. self.folder_name = "Java源码"
  65. self.second_column_name = "572_517"
  66. elif title_name == "HTML":
  67. self.folder_name = "HTML-CSS源码"
  68. self.second_column_name = "608_572"
  69. elif title_name == "TypeScript":
  70. self.folder_name = "TypeScript源码"
  71. self.second_column_name = "772_572"
  72. elif title_name == "微信小程序":
  73. self.folder_name = "微信小程序源码"
  74. self.second_column_name = "610_572"
  75. elif title_name == "Ruby":
  76. self.folder_name = "Ruby源码"
  77. self.second_column_name = "622_572"
  78. elif title_name == "NodeJs":
  79. self.folder_name = "NodeJs源码"
  80. self.second_column_name = "626_572"
  81. elif title_name == "C++":
  82. self.folder_name = "C++源码"
  83. self.second_column_name = "596_572"
  84. elif title_name == "C":
  85. self.folder_name = "C源码"
  86. self.second_column_name = "594_572"
  87. #https://down.chinaz.com/class/594_572_1.htm
  88. first_column_name = title_name # 一级目录
  89. second_folder_name = str(self.sprider_count) + "个" + self.folder_name #二级目录
  90. self.sprider_type =second_folder_name
  91. self.merchant=int(self.sprider_start_count) //int(self.max_pager)+1 #起始页码用于效率采集
  92. self.file_path = self.save_path + os.sep + "Code" + os.sep + first_column_name + os.sep + second_folder_name
  93. self.save_path = self.save_path+ os.sep + "Code" + os.sep+first_column_name+os.sep + second_folder_name+ os.sep + self.folder_name
  94. BaseFrame().debug("开始采集ChinaZCode"+self.folder_name+"...")
  95. sprider_url = (self.base_url + "/class/{0}_1.htm".format(self.second_column_name))
  96. down_path="D:\\Freedom\\Sprider\\ChinaZ\\Code\\"+first_column_name+"\\"+second_folder_name+"\\Temp\\"
  97. if os.path.exists(down_path) is True:
  98. shutil.rmtree(down_path)
  99. if os.path.exists(down_path) is False:
  100. os.makedirs(down_path)
  101. if os.path.exists(self.save_path ) is True:
  102. shutil.rmtree(self.save_path )
  103. if os.path.exists(self.save_path ) is False:
  104. os.makedirs(self.save_path )
  105. chrome_options = webdriver.ChromeOptions()
  106. diy_prefs ={'profile.default_content_settings.popups': 0,
  107. 'download.default_directory':'{0}'.format(down_path)}
  108. # 添加路径到selenium配置中
  109. chrome_options.add_experimental_option('prefs', diy_prefs)
  110. chrome_options.add_argument('--headless') #隐藏浏览器
  111. # 实例化chrome浏览器时,关联忽略证书错误
  112. driver = webdriver.Chrome(options=chrome_options)
  113. driver.set_window_size(1280, 800) # 分辨率 1280*800
  114. # driver.get方法将定位在给定的URL的网页,get接受url可以是任何网址,此处以百度为例
  115. driver.get(sprider_url)
  116. # content = driver.page_source
  117. # print(content)
  118. div_elem = driver.find_element(By.CLASS_NAME, "main") # 列表页面 核心内容
  119. element_list = div_elem.find_elements(By.CLASS_NAME, 'item')
  120. laster_pager_ul = driver.find_element(By.CLASS_NAME, "el-pager")
  121. laster_pager_li =laster_pager_ul.find_elements(By.CLASS_NAME, 'number')
  122. laster_pager_url = laster_pager_li[len(laster_pager_li) - 1]
  123. page_end_number = int(laster_pager_url.text)
  124. self.page_count=self.merchant
  125. while self.page_count <= int(page_end_number): # 翻完停止
  126. try:
  127. if self.page_count == 1:
  128. self.sprider_detail(driver,element_list,self.page_count,page_end_number,down_path)
  129. pass
  130. else:
  131. if self.haved_sprider_count == self.sprider_count:
  132. BaseFrame().debug("采集到达数量采集停止...")
  133. BaseFrame().debug("开始写文章...")
  134. self.builder_word(self.folder_name, self.save_path, self.word_content_list)
  135. BaseFrame().debug("文件编写完毕,请到对应的磁盘查看word文件和下载文件!")
  136. break
  137. #(self.base_url + "/sort/{0}/{1}/".format(url_index, self.page_count))
  138. #http://soft.onlinedown.net/sort/177/2/
  139. next_url = self.base_url + "/class/{0}_{1}.htm".format(self.second_column_name, self.page_count)
  140. driver.get(next_url)
  141. div_elem = driver.find_element(By.CLASS_NAME, "main") # 列表页面 核心内容
  142. element_list = div_elem.find_elements(By.CLASS_NAME, 'item')
  143. self.sprider_detail( driver, element_list, self.page_count, page_end_number, down_path)
  144. pass
  145. #print(self.page_count)
  146. self.page_count = self.page_count + 1 # 页码增加1
  147. except Exception as e:
  148. print("sprider()执行过程出现错误:" + str(e))
  149. sleep(1)
  150. def sprider_detail(self, driver,element_list,page_count,max_page,down_path):
  151. """
  152. 采集明细页面
  153. :param driver:
  154. :param element_list:
  155. :param page_count:
  156. :param max_page:
  157. :param down_path:
  158. :return:
  159. """
  160. index = 0
  161. element_array=[]
  162. element_length=len(element_list)
  163. for element in element_list:
  164. url_A_obj = element.find_element(By.CLASS_NAME, 'name-text')
  165. next_url = url_A_obj.get_attribute("href")
  166. coder_title = url_A_obj.get_attribute("title")
  167. e=coder_title+"$"+ next_url
  168. element_array.append(e)
  169. pass
  170. if int(self.page_count) == int(self.merchant):
  171. self.sprider_start_index = int(self.sprider_start_count) % int(self.max_pager)
  172. index=self.sprider_start_index
  173. while index < element_length:
  174. if os.path.exists(down_path) is False:
  175. os.makedirs(down_path)
  176. if self.haved_sprider_count == self.sprider_count:
  177. BaseFrame().debug("采集到达数量采集停止...")
  178. break
  179. #element = element_list[index]
  180. element=element_array[index]
  181. time.sleep(1)
  182. index = index + 1
  183. sprider_info="正在采集第"+str(page_count)+"页的第"+str(index)+"个资源,共"+str(max_page)+"页资源"
  184. BaseFrame().debug(sprider_info)
  185. next_url=element.split("$")[1]
  186. coder_title=element.split("$")[0]
  187. # next_url = element.find_element(By.TAG_NAME, 'a').get_attribute("href")
  188. # coder_title =element.find_element(By.TAG_NAME, 'img').get_attribute("title")
  189. driver.get(next_url) # 请求明细页面
  190. try:
  191. # codeEntity = SpriderEntity() # 下载过的资源不再下载
  192. # codeEntity.sprider_base_url = self.base_url
  193. # codeEntity.create_datetime = SpriderTools.get_current_datetime()
  194. # codeEntity.sprider_url = next_url
  195. # codeEntity.sprider_pic_title = coder_title
  196. # codeEntity.sprider_pic_index = str(index)
  197. # codeEntity.sprider_pager_index = page_count
  198. # codeEntity.sprider_type = self.sprider_type
  199. # if SpriderAccess().query_sprider_entity_by_urlandindex(next_url, str(index)) is None:
  200. # SpriderAccess().save_sprider(codeEntity)
  201. # else:
  202. # BaseFrame().debug(coder_title+next_url + "数据采集过因此跳过")
  203. # continue
  204. if SeleniumTools.judeg_element_isexist(driver, "CLASS_NAME", "download-item") == 3:
  205. driver.back()
  206. BaseFrame().debug(coder_title+"不存在源码是soft因此跳过哦....")
  207. continue
  208. print("准备点击下载按钮...")
  209. driver.find_element(By.CLASS_NAME, "download-item").click() #下载源码
  210. sleep(1)
  211. result,message=SpriderTools.judge_file_exist(True,240,1,down_path,"zip|rar|gz|tgz")#判断源码
  212. if result is True:
  213. sprider_content = [coder_title, self.save_path + os.sep +"image"+ os.sep + coder_title + ".jpg"] # 采集成功的记录
  214. self.word_content_list.append(sprider_content) # 增加到最终的数组
  215. self.haved_sprider_count = self.haved_sprider_count + 1
  216. BaseFrame().debug("已经采集完成第" + str(self.haved_sprider_count) + "个")
  217. time.sleep(1)
  218. driver.back()
  219. coder_title = str(coder_title).replace("/", "") #去掉windows不识别的字符
  220. files = os.listdir(down_path)
  221. file_name = files[0] #获取默认值
  222. if len(self.filter_down_file)>0:
  223. for file in files:
  224. for filter_file in self.filter_down_file:
  225. if str(file) in str(filter_file):
  226. BaseFrame().error(filter_file + "文件被过滤...")
  227. pass
  228. else:
  229. file_name = file
  230. srcFile = down_path + os.sep + file_name
  231. file_ext = os.path.splitext(srcFile)[-1]
  232. dstFile = down_path + os.sep + coder_title + file_ext
  233. os.rename(srcFile, dstFile)
  234. srcFile = dstFile
  235. dstFile = self.save_path + os.sep + coder_title + file_ext
  236. shutil.move(srcFile, dstFile) # 移动文件
  237. else:
  238. files = os.listdir(down_path) # 读取目录下所有文件
  239. coder_title = str(coder_title).replace("/", "") # 去掉windows不识别的字符
  240. try:
  241. if str(message)=="0个文件认定是False":
  242. BaseFrame().error(coder_title+"文件不存在...")
  243. shutil.rmtree(down_path) # 如果没下载完是无法删除的
  244. pass
  245. else:
  246. BaseFrame().error("检测下载文件出错可能原因是等待时间不够已经超时,再等待60秒...")
  247. time.sleep(60)
  248. shutil.rmtree(down_path) #如果没下载完是无法删除的
  249. #清空数组
  250. self.filter_down_file.clear()
  251. except Exception as e:
  252. # 使用数组append记录文件名字 移动的时候过滤
  253. self.builder_filter_file(files)
  254. pass
  255. except Exception as e:
  256. BaseFrame().error("sprider_detail()执行过程出现错误:" + str(e))
  257. BaseFrame().error("sprider_detail()记录下载的文件名")
  258. # 使用数组append记录文件名字 移动的时候过滤
  259. files = os.listdir(down_path) # 读取目录下所有文件
  260. self.builder_filter_file(files)
  261. if(int(page_count)==int(max_page)):
  262. self.builder_word(self.folder_name,self.save_path,self.word_content_list)
  263. BaseFrame().debug("文件编写完毕,请到对应的磁盘查看word文件和下载文件!")
  264. def builder_filter_file(self,files):
  265. for file in files:
  266. self.filter_down_file.append(str(file))
  267. pass
  268. def builder_word(self, word_title, save_path, list_files):
  269. """
  270. 输出产物是word文件
  271. :param word_title: 文件的标题
  272. :param save_path: 文件的保存路径
  273. :param list_files: 文件集合(单个内容)
  274. :return:
  275. """
  276. try:
  277. self.copy_file(self.save_path)
  278. print("Create Word"+word_title)
  279. file_count= len(list_files)
  280. self.gen_passandtxt(file_count,word_title,list_files)
  281. random_full_file_name = SpriderTools.get_word_image("java",6)
  282. document = Document()
  283. document.add_heading(""+word_title+"", level=2)
  284. document.add_paragraph("分享"+str(file_count)+"个"+word_title+",总有一款适合您\r\n"
  285. "下面是文件的名字,我放了一些图片,文章里不是所有的图主要是放不下...,大家下载后可以看到。")
  286. document.add_paragraph("源码下载")
  287. document.add_picture(random_full_file_name, width=Inches(3))
  288. ppt_tieles = ""
  289. for files in list_files:
  290. ppt_tieles = ppt_tieles + str(files[0]) + "\r"
  291. document.add_paragraph(ppt_tieles)
  292. # for files in list_files:
  293. # try:
  294. # document.add_paragraph(files[0])
  295. # document.add_picture(files[1], width=Inches(3))
  296. # except Exception as e:
  297. # pass
  298. document.add_paragraph("最后送大家一首诗:")
  299. paragraph = document.add_paragraph() # 单独控制
  300. paragraph.add_run("山高路远坑深,\r")
  301. paragraph.add_run("大军纵横驰奔,\r")
  302. paragraph.add_run("谁敢横刀立马?\r")
  303. paragraph.add_run("惟有点赞加关注大军。\r")
  304. paragraph.bold = True # 字体加粗
  305. file_full_path=self.file_path+os.sep+word_title+".docx"
  306. document.save(file_full_path)
  307. except Exception as e:
  308. print("Create Word Fail reason:" + str(e))
  309. def copy_file(self,target_path):
  310. print("copy files")
  311. import os
  312. import shutil
  313. src_apk_file_path="亚丁号自动阅读_v0.0.53.apk"
  314. dst_apk_file_path=self.file_path+os.sep+"亚丁号自动阅读_v0.0.53.apk"
  315. shutil.copyfile(src_apk_file_path, dst_apk_file_path) # 移动文件
  316. src_pdf_file_path = "薅羊毛专业版.pdf"
  317. dst_pdf_file_path = target_path + os.sep + "薅羊毛专业版.pdf"
  318. #shutil.copyfile(src_pdf_file_path, dst_pdf_file_path) # 移动文件
  319. src_pdf_file_path = "亚丁号.url"
  320. dst_pdf_file_path = self.file_path + os.sep + "亚丁号.url"
  321. shutil.copyfile(src_pdf_file_path, dst_pdf_file_path) # 移动文件
  322. src_doc_file_path = "readme.docx"
  323. dst_doc_file_path = self.file_path + os.sep + "readme.docx"
  324. shutil.copyfile(src_doc_file_path, dst_doc_file_path) # 移动文件
  325. pass
  326. def gen_passandtxt(self,file_count,word_title, list_files):
  327. print("Create PassWord and Pass.txt")
  328. message=SpriderTools.gen_password()
  329. password = "".join(message)
  330. content=""
  331. content = content + "\n分享"+str(file_count)+"个"+word_title+",总有一款适合您"
  332. content = content + "\n\r"
  333. content=content+"\n都到这里了您就支持一下呗!谢谢老铁~~"
  334. content=content+"\n\r"
  335. # content = content + "\n\r"
  336. # content = content + "\n\r"
  337. # for files in list_files:
  338. # content = content+str(files[0])+ "\n"
  339. content=content+"\n文件我就不一一列举了,送老铁一首打油诗"
  340. content=content+"\n学习知识费力气,"
  341. content=content+"\n收集整理更不易。"
  342. content=content+"\n知识付费甚欢喜,"
  343. content=content+"\n为咱码农谋福利。"
  344. content=content+"\n\r"
  345. content=content+"\n\r"
  346. content=content+"\n感谢您的支持"
  347. content=content+"\n\r"
  348. content=content+"\n-------------------------------------------华丽分割线-------------------------------------------------------"
  349. content=content+"\n友情提醒解压密码:"+password+""
  350. full_path=self.file_path+os.sep+""+str(file_count)+"sell_pass.txt"
  351. with open(full_path, 'a', encoding='utf-8') as f:
  352. f.write(content)
  353. if __name__ == "__main__":
  354. HuaJunCode().sprider("C")
  355. pass

雷傲LB5000MX v2.00(5.26更新)
Yuzi调查引擎2000多用户版 v1.16
未名新闻WMnews v3.2
未名留言本wmguestbook v1.0
Discoco.com LBXP v3.0 1201 国际版论坛
7RPClub Vc1.08
枫叶情缘 v2.02 纪念版
枫叶情缘 v1.6 完整版
贝特协同办公系统(BetterCOS) v2.06
机器人大战EBS(无尽的战争)
纯蓝音乐在线 v1.0
Discoco.com LB论坛程序 国际版 v2.0
LB 热浪论坛 v2.15
LB5000XP 1201 七星瓢虫美化版
NiceUBB v3.50 正式版
蓝色冥想留言簿 v3.1(文本)
NetBoard XTeam 讨论板 v1.0
iLcatForums 论坛系统
Nkshop网上商店程序
UT 最新的3个小hack v1.0
Ultimate Bulletin Board Classic v6.4 零售版
晓冉文章管理系统 v3.0.4 特别版
ubbthreads v5.51 中文简体版(perl版)
YABBCN v1.0 论坛
igb留言板 v3.5 up
YxBBS 2003(bbs3000修改版)
ut 2hacker 代码 v1.0
Ken’s Shell v1.0MXP 正式版
Ken's Shell v1.0mxp 繁体版
Ikonboard v3.1.1 v2002.11.01 中文版
LB 戈美化版
雷傲LB5000XP 新好男孩 hack v0731 F8City修改版
80多个外国商业源代码 v1.0
卓越BBS v4.123
网酷饼图投票系统 v1.0 Beta 0820
UltraThreads  v1.0 HACK
漂流瓶-卓越版
Yuzi域名系统3000(NAME3000) v1.00
SODBBS v4.25
UltraThreads v1.0
UltraThreads v1.0 升级版
WebFTP
AGBII v1.0 多用户版(注册版)
乾坤小小挪移 v1.5 Beta 3
Sharin'Ware 在线上传下载软件管理器
角本中国之软件下载系统
软件下载管理程序
软件下载系统
梦幻软件下载系统DDdown v1.0
Yuzi软件下载2000 v1.20版
软件下载系统
软件下载管理程序
Yuzi软件下载2000 v1.20版
Hicao会员管理+页面保护(三代)超强系统
蓝图画廊 v2.0(单用户版)
WhoIs v1.0(域名查询程序)
易得多用户论坛TXT商业版 v1.63 Build 20001213
MYBBS 论坛 v6.01 多用户版
伊米论坛 v2.1
天空论坛
高山论坛
DBMEdit v1.0(数据库管理程序)
Bookmarks Tree Creator v1.0(书签程序)
站内搜索
UltraBoard v1.62
ABS Classified Ads v5.0.6 Free
BoardMaster v1.82
FlasH BBS Pro v1.40
DDart BOARD 2000 v1.1 BETA5 汉化版
rpgboard v2.10a
sporum v1.5.1
Forum Engine 2000 汉化版
WDW v2.0 汉化版
东木书屋CqiaoBBS论坛
BM 2000最新hack 01
IkonBoard论坛汉化版
Anyboardv v7.3.2
BoardMaster 2001 汉化版
IB2000 超级论坛 0303
TECHNOTE 2000 商业版
梦之星DreamBoard
WWW BBS v3.0
BoardMaster v1.82 Build 642 中文版完整版
Anyboard v7.0.0 中文版
二手交易市场
跳蚤市场 v1.00
西風跳蚤市场(繁体版)
Bookmarks Tree Creator v1.0(书签程序)
DBMEdit v1.0(数据库管理程序)
Forum Engine 2000
RobBoard v1.0B
UltraBoard v1.62
高山论坛
天空论坛
伊米论坛 v2.1
MYBBS 论坛 v6.01 多用户版
易得多用户论坛TXT商业版 v1.63 Build 20001213
UBB v5.47D 英文版
OKbook 暗笑汉化版本
SPboard v4.5 汉化版
BillowBBS v3.0 汉化修改版
Banner Plus v1.0(广告交换系统)
Banner随机显示
广告交换 v1.0 Beta
Easy v1.03
网盟广告交换系统
非凡网盟广告交换系统
广告付费系统 v2.82
Sponsor Me (一个来自国外的广告程序)
网酷广告递送 v1.0 Beta 0820
ADCenter 2000 v3.1豪华版
 

  1. # -*- coding: utf-8 -*-
  2. import os
  3. def file_name(file_dir):
  4. for file in os.listdir(file_dir):
  5. print(file)
  6. if __name__=="__main__":
  7. file_name("D:\Freedom\Sprider\ChinaZ\Code\C\\36个C源码\C源码")
  8. pass

最后送大家一首诗:

山高路远坑深,
大军纵横驰奔,
谁敢横刀立马?
惟有点赞加关注大军。
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/757005
推荐阅读
相关标签
  

闽ICP备14008679号