Python写网络爬虫(一)

关于Python:

学过C. 学过C++. 最后还是学Java来吃饭.

一直在Java的小世界里混迹.

有句话说: “Life is short, you need Python!”  翻译过来就是: 人生苦短, 我用Python

到底它有多么强大,  多么简洁?

抱着这个好奇心, 趁不忙的几天. 还是忍不住的小学了一下.(- - 事实上学了还不到两天)

随便用一个"HelloWorld"的样例

  1. //Java
  2. class Main{
  3. public static void main(String[] args){
  4. String str = "HelloWorld!";
  5. System.out.println(str);
  6. }
  7. }
  1. #Python
  2. str = 'HelloWorld'
  3. print str

乍一看Python确实非常爽! 简明了断 节省时间

至于效率. 我相信无论是不论什么语言, 作为开发人员重要是的还是思维的精简!

也有人说: "Python一时爽, 重构火葬场"

可是Python的应用场景那么多. 依据自己的须要来选择, 相信那么多前辈没错.

Python的确是一门值得学习的课程.

关于网络爬虫:

这个东西我也也不懂... 随便抓个解释, 淡淡的理解下
网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更常常的称为网页追逐者)。是一种依照一定的规则。自己主动地抓取万维网信息的程序或者脚本。另外一些不常使用的名字还有蚂蚁、自己主动索引、模拟程序或者蠕虫。 
真正的复杂而强大的爬虫有非常多爬行算法和策略.
我写的这个样例简直是简之又简. 

Python基础还没学完, 就迫不及待的想做个东西来看看

于是就想到了写个网络爬虫. 来小小的练习一下

我的母校是甘肃农大. 我会常常看学校新闻, 于是就试着爬个学校新闻, 没事的时候拿出来看看

由于学的甚少...这个爬虫的功能还是很easy. 就是把学校官网中最新的新闻下载下来, 保存成网页. 想看多少页都能够.

这里我就抓了最新的前4页新闻

第一次写爬虫. 一个非常easy的功能, 我把它分了3步:

第一步: 先爬一条新闻, 把它下载保存!

第二部: 把这一页的全部新闻都爬下来, 下载保存!

第三部: 把x页的全部新闻爬下来, 下载保存!

网页爬虫非常重要的一点就是分析网页元素.

第一步: 先来爬一个url的内容

  1. #crawler: 甘肃农业大学新闻网板块的->学校新闻.
  2. #爬这个页面的第一篇新闻
  3. #http://news.gsau.edu.cn/tzgg1/xxxw33.htm
  4.  
  5. #coding:utf-8
  6. import urllib
  7.  
  8. str = '<a class="c43092" href="../info/1037/30577.htm" target="_blank" title="双联行动水泉乡克那村工作组赴联系村开展精准扶贫相关工作">双联行动水泉乡克那村工作组赴联系村开展精准扶贫相关工作</a>'
  9.  
  10. hrefBeg = str.find('href=')
  11. hrefEnd = str.find('.htm', hrefBeg)
  12. href = str[hrefBeg+6: hrefEnd+4]
  13. print href
  14. href = href[3:]
  15. print href
  16.  
  17. titleBeg = str.find(r'title=')
  18. titleEnd = str.find(r'>', titleBeg)
  19. title = str[titleBeg+7: titleEnd-1]
  20. print title
  21.  
  22. url = 'http://news.gsau.edu.cn/' + href
  23. print 'url: '+url
  24.  
  25. content = urllib.urlopen(url).read()
  26. #print content
  27.  
  28. filename = title + '.html'
  29. #将抓取的页面content写入filename保存本地文件夹中
  30. open(filename, 'w').write(content)

这个里面不用分析太多网页元素. 就字符串拼阿截阿就好了.

第二步: 爬取本页面的全部新闻, 每页23篇

这个时候就要小小的分析下, 这23个url, 每一个url怎么找?

这里能够先锁定一个元素, 进行查找. 再就是注意每次find时的规律, 事实上就是查找的顺序起始

这里我把每一个url都保存在一个数组中, 检索完毕后, 对数组里的url进行下载.

  1. #crawler甘肃农业大学新闻网板块的->学校新闻.
  2. #http://news.gsau.edu.cn/tzgg1/xxxw33.htm
  3.  
  4. #<a class="c43092" href="../info/1037/30567.htm" target="_blank" title="双联行动水泉乡克那村工作组赴联系村开展精准扶贫相关工作">双联行动水泉乡克那村工作组赴联系村开展精准扶贫相关工作</a>
  5. #coding:utf-8
  6. import urllib
  7. import time
  8. import stat, os
  9.  
  10. pageSize = 23
  11. articleList = urllib.urlopen('http://news.gsau.edu.cn/tzgg1/xxxw33.htm').read()
  12. urlList = [' ']*pageSize
  13. #锁定class="c43092"
  14. hrefClass = articleList.find('class="c43092"')
  15. hrefBeg = articleList.find(r'href=', hrefClass)
  16. hrefEnd = articleList.find(r'.htm', hrefBeg)
  17. href=articleList[hrefBeg+6: hrefEnd+4][3:]
  18. print href
  19.  
  20. #url = 'http://news.gsau.edu.cn/' + href
  21. #print 'url: '+url
  22.  
  23. i = 0
  24. while href!=-1 and i<pageSize:
  25. urlList[i] = 'http://news.gsau.edu.cn/' + href
  26.  
  27. hrefClass = articleList.find('class="c43092"', hrefEnd)
  28. hrefBeg = articleList.find(r'href=', hrefClass)
  29. hrefEnd = articleList.find(r'.htm', hrefBeg)
  30. href=articleList[hrefBeg+6: hrefEnd+4][3:]
  31. print urlList[i]
  32. i = i+1
  33. else:
  34. print r'本页所有URL已爬完!!!'
  35.  
  36. #将本页每一篇新闻下载到本地(已新闻标题文件名称存储)
  37. #title: <HTML><HEAD><TITLE>酒泉市市长都伟来校对接校地合作事宜-新闻网</TITLE>
  38. j = 0
  39. while j<pageSize:
  40. content = urllib.urlopen(urlList[j]).read()
  41. titleBeg = content.find(r'<TITLE>')
  42. titleEnd = content.find(r'</TITLE>', titleBeg)
  43. title = content[titleBeg+7: titleEnd]
  44. print title
  45. print urlList[j]+r'正在下载...'
  46. time.sleep(1)
  47. open(r'GsauNews' + os.path.sep + title.decode('utf-8').encode('gbk')+'.html', 'w+').write(content)
  48. j = j + 1
  49. else:
  50. print r'当页所有url完成下载!'

第三步: 爬取N个页面的全部新闻

这里要爬取N个页面, 首先就要分析你要爬取的是最新的, 而不能是固定的某几页

所以要分析下分页的数据, 正好主页最以下也给出了分页数据, 直接用它!

看下近期几页的url:

  1. #http://news.gsau.edu.cn/tzgg1/xxxw33.htm 第一页
  2. #http://news.gsau.edu.cn/tzgg1/xxxw33/221.htm 第二页
  3. #http://news.gsau.edu.cn/tzgg1/xxxw33/220.htm 第三页
  4. #http://news.gsau.edu.cn/tzgg1/xxxw33/219.htm 第四页

对照分页数据, 非常easy发现规律, 就是: fenyeCount-pageNo+1

这里非常烦的一点是不知道为什么, 除了第一页以外的其它页, 都会有不是本页而是前一页的一部分网页数据会掺进来. 导致我找了半天

做了非常多推断才检索出来

  1. #crawler甘肃农业大学新闻网板块的->学校新闻.
  2.  
  3. #coding:utf-8
  4. import urllib
  5. import time
  6. import stat, os
  7.  
  8. pageCount = 4
  9. pageSize = 23
  10. pageNo = 1
  11. urlList = [' ']*pageSize*pageCount
  12.  
  13. #分析分页的网页元素
  14. #<td width="1%" align="left" id="fanye43092" nowrap="">共5084条  1/222 </td>
  15. indexContent = urllib.urlopen('http://news.gsau.edu.cn/tzgg1/xxxw33.htm').read()
  16. fenyeId = indexContent.find('id="fanye43092"') #这里锁定分页的id进行查找
  17. fenyeBeg = indexContent.find('1/', fenyeId)
  18. fenyeEnd = indexContent.find(' ', fenyeBeg)
  19. fenyeCount = int(indexContent[fenyeBeg+2: fenyeEnd])
  20.  
  21. i = 0
  22. while pageNo <= pageCount:
  23. if pageNo==1:
  24. articleUrl = 'http://news.gsau.edu.cn/tzgg1/xxxw33.htm'
  25. else:
  26. articleUrl = 'http://news.gsau.edu.cn/tzgg1/xxxw33/'+ str(fenyeCount-pageNo+1) + '.htm'
  27.  
  28. print r'--------共爬取'+ str(pageCount) + '页 当前第' + str(pageNo) + '页 URL:' + articleUrl
  29.  
  30. articleList = urllib.urlopen(articleUrl).read()
  31.  
  32. while i<pageSize*pageNo:
  33.  
  34. if pageNo == 1:
  35. #i = 0,23,46...时,从头找, 其余从上一个url结束位置开找
  36. if i == pageSize*(pageNo-1):
  37. hrefId = articleList.find('id="line43092_0"')
  38. else:
  39. hrefId = articleList.find('class="c43092"', hrefEnd)
  40. else:
  41. if i == pageSize*(pageNo-1):
  42. hrefId = articleList.find('id="lineimg43092_16"')
  43. else:
  44. hrefId = articleList.find('class="c43092"', hrefEnd)
  45.  
  46. hrefBeg = articleList.find(r'href=', hrefId)
  47. hrefEnd = articleList.find(r'.htm', hrefBeg)
  48. if pageNo == 1:
  49. href=articleList[hrefBeg+6: hrefEnd+4][3:]
  50. else:
  51. href=articleList[hrefBeg+6: hrefEnd+4][6:]
  52. urlList[i] = 'http://news.gsau.edu.cn/' + href
  53.  
  54. print urlList[i]
  55. i = i+1
  56. else:
  57. print r'========第'+str(pageNo)+'页url提取完毕!!!'
  58.  
  59. pageNo = pageNo + 1
  60. print r'============全部url提取完毕!!!============'+'\n'*3
  61.  
  62. print r'==========開始下载到本地==========='
  63. j = 0
  64. while j < pageCount * pageSize:
  65. content = urllib.urlopen(urlList[j]).read()
  66. titleBeg = content.find(r'<TITLE>')
  67. titleEnd = content.find(r'</TITLE>', titleBeg)
  68. title = content[titleBeg+7: titleEnd]
  69. print title
  70. print urlList[j]+r'正在下载...'+'\n'
  71. time.sleep(1)
  72. open(r'GsauNews' + os.path.sep + title.decode('utf-8').encode('gbk')+'.html', 'w+').write(content)
  73. j = j + 1
  74. else:
  75. print r'下载完毕, 共下载'+str(pageCount)+'页, '+str(pageCount*pageSize)+'篇新闻'

这就爬完了....

看下爬完的效果

  1. ==================== RESTART: D:\python\CSDNCrawler03.py ====================
  2. --------共爬取4 当前第1 URL:http://news.gsau.edu.cn/tzgg1/xxxw33.htm
  3. http://news.gsau.edu.cn/info/1037/30596.htm
  4. http://news.gsau.edu.cn/info/1037/30595.htm
  5. http://news.gsau.edu.cn/info/1037/30593.htm
  6. http://news.gsau.edu.cn/info/1037/30591.htm
  7. http://news.gsau.edu.cn/info/1037/30584.htm
  8. http://news.gsau.edu.cn/info/1037/30583.htm
  9. http://news.gsau.edu.cn/info/1037/30580.htm
  10. http://news.gsau.edu.cn/info/1037/30577.htm
  11. http://news.gsau.edu.cn/info/1037/30574.htm
  12. http://news.gsau.edu.cn/info/1037/30573.htm
  13. http://news.gsau.edu.cn/info/1037/30571.htm
  14. http://news.gsau.edu.cn/info/1037/30569.htm
  15. http://news.gsau.edu.cn/info/1037/30567.htm
  16. http://news.gsau.edu.cn/info/1037/30566.htm
  17. http://news.gsau.edu.cn/info/1037/30565.htm
  18. http://news.gsau.edu.cn/info/1037/30559.htm
  19. http://news.gsau.edu.cn/info/1037/30558.htm
  20. http://news.gsau.edu.cn/info/1037/30557.htm
  21. http://news.gsau.edu.cn/info/1037/30555.htm
  22. http://news.gsau.edu.cn/info/1037/30554.htm
  23. http://news.gsau.edu.cn/info/1037/30546.htm
  24. http://news.gsau.edu.cn/info/1037/30542.htm
  25. http://news.gsau.edu.cn/info/1037/30540.htm
  26. ========第1url提取完毕!!!
  27. --------共爬取4 当前第2 URL:http://news.gsau.edu.cn/tzgg1/xxxw33/221.htm
  28. http://news.gsau.edu.cn/info/1037/30536.htm
  29. http://news.gsau.edu.cn/info/1037/30534.htm
  30. http://news.gsau.edu.cn/info/1037/30528.htm
  31. http://news.gsau.edu.cn/info/1037/30525.htm
  32. http://news.gsau.edu.cn/info/1037/30527.htm
  33. http://news.gsau.edu.cn/info/1037/30524.htm
  34. http://news.gsau.edu.cn/info/1037/30520.htm
  35. http://news.gsau.edu.cn/info/1037/30519.htm
  36. http://news.gsau.edu.cn/info/1037/30515.htm
  37. http://news.gsau.edu.cn/info/1037/30508.htm
  38. http://news.gsau.edu.cn/info/1037/30507.htm
  39. http://news.gsau.edu.cn/info/1037/30506.htm
  40. http://news.gsau.edu.cn/info/1037/30505.htm
  41. http://news.gsau.edu.cn/info/1037/30501.htm
  42. http://news.gsau.edu.cn/info/1037/30498.htm
  43. http://news.gsau.edu.cn/info/1037/30495.htm
  44. http://news.gsau.edu.cn/info/1037/30493.htm
  45. http://news.gsau.edu.cn/info/1037/30482.htm
  46. http://news.gsau.edu.cn/info/1037/30480.htm
  47. http://news.gsau.edu.cn/info/1037/30472.htm
  48. http://news.gsau.edu.cn/info/1037/30471.htm
  49. http://news.gsau.edu.cn/info/1037/30470.htm
  50. http://news.gsau.edu.cn/info/1037/30469.htm
  51. ========第2url提取完毕!!!
  52. --------共爬取4 当前第3 URL:http://news.gsau.edu.cn/tzgg1/xxxw33/220.htm
  53. http://news.gsau.edu.cn/info/1037/30468.htm
  54. http://news.gsau.edu.cn/info/1037/30467.htm
  55. http://news.gsau.edu.cn/info/1037/30466.htm
  56. http://news.gsau.edu.cn/info/1037/30465.htm
  57. http://news.gsau.edu.cn/info/1037/30461.htm
  58. http://news.gsau.edu.cn/info/1037/30457.htm
  59. http://news.gsau.edu.cn/info/1037/30452.htm
  60. http://news.gsau.edu.cn/info/1037/30450.htm
  61. http://news.gsau.edu.cn/info/1037/30449.htm
  62. http://news.gsau.edu.cn/info/1037/30441.htm
  63. http://news.gsau.edu.cn/info/1037/30437.htm
  64. http://news.gsau.edu.cn/info/1037/30429.htm
  65. http://news.gsau.edu.cn/info/1037/30422.htm
  66. http://news.gsau.edu.cn/info/1037/30408.htm
  67. http://news.gsau.edu.cn/info/1037/30397.htm
  68. http://news.gsau.edu.cn/info/1037/30396.htm
  69. http://news.gsau.edu.cn/info/1037/30394.htm
  70. http://news.gsau.edu.cn/info/1037/30392.htm
  71. http://news.gsau.edu.cn/info/1037/30390.htm
  72. http://news.gsau.edu.cn/info/1037/30386.htm
  73. http://news.gsau.edu.cn/info/1037/30385.htm
  74. http://news.gsau.edu.cn/info/1037/30376.htm
  75. http://news.gsau.edu.cn/info/1037/30374.htm
  76. ========第3url提取完毕!!!
  77. --------共爬取4 当前第4 URL:http://news.gsau.edu.cn/tzgg1/xxxw33/219.htm
  78. http://news.gsau.edu.cn/info/1037/30370.htm
  79. http://news.gsau.edu.cn/info/1037/30369.htm
  80. http://news.gsau.edu.cn/info/1037/30355.htm
  81. http://news.gsau.edu.cn/info/1037/30345.htm
  82. http://news.gsau.edu.cn/info/1037/30343.htm
  83. http://news.gsau.edu.cn/info/1037/30342.htm
  84. http://news.gsau.edu.cn/info/1037/30340.htm
  85. http://news.gsau.edu.cn/info/1037/30339.htm
  86. http://news.gsau.edu.cn/info/1037/30335.htm
  87. http://news.gsau.edu.cn/info/1037/30333.htm
  88. http://news.gsau.edu.cn/info/1037/30331.htm
  89. http://news.gsau.edu.cn/info/1037/30324.htm
  90. http://news.gsau.edu.cn/info/1037/30312.htm
  91. http://news.gsau.edu.cn/info/1037/30311.htm
  92. http://news.gsau.edu.cn/info/1037/30302.htm
  93. http://news.gsau.edu.cn/info/1037/30301.htm
  94. http://news.gsau.edu.cn/info/1037/30298.htm
  95. http://news.gsau.edu.cn/info/1037/30294.htm
  96. http://news.gsau.edu.cn/info/1037/30293.htm
  97. http://news.gsau.edu.cn/info/1037/30289.htm
  98. http://news.gsau.edu.cn/info/1037/30287.htm
  99. http://news.gsau.edu.cn/info/1037/30286.htm
  100. http://news.gsau.edu.cn/info/1037/30279.htm
  101. ========第4url提取完毕!!!
  102. ============全部url提取完毕!!!============
  103.  
  104. ==========開始下载到本地===========
  105. 甘肃爽口源生态科技股份有限公司来校洽谈校企合作-新闻网
  106. http://news.gsau.edu.cn/info/1037/30596.htm正在下载...
  107.  
  108. 我校第二届辅导员职业能力大赛圆满落幕-新闻网
  109. http://news.gsau.edu.cn/info/1037/30595.htm正在下载...
  110.  
  111. 双联行动周家山村工作组开展精准扶贫工作-新闻网
  112. http://news.gsau.edu.cn/info/1037/30593.htm正在下载...
  113.  
  114. 新疆生产建设兵团来校举办专场校园招聘会-新闻网
  115. http://news.gsau.edu.cn/info/1037/30591.htm正在下载...
  116.  
  117. 【图片新闻】桃李吐新叶 羲园醉春风-新闻网
  118. http://news.gsau.edu.cn/info/1037/30584.htm正在下载...
  119.  
  120. 甘农师生爱心救助白血病学生张渭-新闻网
  121. http://news.gsau.edu.cn/info/1037/30583.htm正在下载...
  122.  
  123. 副校长赵兴绪带队赴新庄村开展精准扶贫相关工作-新闻网
  124. http://news.gsau.edu.cn/info/1037/30580.htm正在下载...
  125.  
  126. 双联行动红庄村工作组开展精准扶贫工作-新闻网
  127. http://news.gsau.edu.cn/info/1037/30577.htm正在下载...
  128.  
  129. 校长吴建民带队赴广河县开展精准扶贫和双联工作-新闻网
  130. http://news.gsau.edu.cn/info/1037/30574.htm正在下载...
  131.  
  132. 动物医学院赴园子村开展精准扶贫相关工作-新闻网
  133. http://news.gsau.edu.cn/info/1037/30573.htm正在下载...
  134.  
  135. ..........

一分多钟爬了90个网页.

当然代码还能够优化好多. 可是我Python基础实在薄弱.还是去恶补

还能够继续升级, 用正则, 匹配自己想要的内容,而不是像这样泛泛全保存下来.

能够在以后的学习中继续改进. 爬些更有意思的东西

做这个样例仅仅是为了看看, 初学Python能为我做什么.

Python写爬虫-爬甘农大学校新闻的更多相关文章

  1. Python写爬虫爬妹子

    最近学完Python,写了几个爬虫练练手,网上的教程有很多,但是有的已经不能爬了,主要是网站经常改,可是爬虫还是有通用的思路的,即下载数据.解析数据.保存数据.下面一一来讲.   1.下载数据 首先打 ...

  2. 用Python写爬虫爬取58同城二手交易数据

    爬了14W数据,存入Mongodb,用Charts库展示统计结果,这里展示一个示意 模块1 获取分类url列表 from bs4 import BeautifulSoup import request ...

  3. 利用Python网络爬虫爬取学校官网十条标题

    利用Python网络爬虫爬取学校官网十条标题 案例代码: # __author : "J" # date : 2018-03-06 # 导入需要用到的库文件 import urll ...

  4. python写爬虫时的编码问题解决方案

    在使用Python写爬虫的时候,常常会遇到各种令人抓狂的编码错误问题.下面给出一些简单的解决编码错误问题的思路,希望对大家有所帮助. 首先,打开你要爬取的网站,右击查看源码,查看它指定的编码是什么,如 ...

  5. 如何利用Python网络爬虫爬取微信朋友圈动态--附代码(下)

    前天给大家分享了如何利用Python网络爬虫爬取微信朋友圈数据的上篇(理论篇),今天给大家分享一下代码实现(实战篇),接着上篇往下继续深入. 一.代码实现 1.修改Scrapy项目中的items.py ...

  6. 《用Python写爬虫》学习笔记(一)

    注:纯文本内容,代码独立另写,属于本人学习总结,无任何商业用途,在此分享,如有错误,还望指教. 1.为什么需要爬虫? 答:目前网络API未完全放开,所以需要网络爬虫知识. 2.爬虫的合法性? 答:爬虫 ...

  7. 怎么用Python写爬虫抓取网页数据

    机器学习首先面临的一个问题就是准备数据,数据的来源大概有这么几种:公司积累数据,购买,交换,政府机构及企业公开的数据,通过爬虫从网上抓取.本篇介绍怎么写一个爬虫从网上抓取公开的数据. 很多语言都可以写 ...

  8. 开发记录_自学Python写爬虫程序爬取csdn个人博客信息

    每天刷开csdn的博客,看到一整个页面,其实对我而言,我只想看看访问量有没有上涨而已... 于是萌生了一个想法: 想写一个爬虫程序把csdn博客上边的访问量和评论数都爬下来. 打算通过网络各种搜集资料 ...

  9. 定向爬虫之爬一爬各个学校新闻的认识(【1】对Url的认识)

    昨天早上,我习惯性的打开博客园,看一看别人的写的博客.突然想起,自己好像没有写过什么博客,所以就心血来潮,把我现在做得事情写出来, 这也是对我目前的学习的一种总结.望大神指点.... 对于一间学校的新 ...

随机推荐

  1. Perl初学笔记

    标量数据 标量:数字和字符串. 数字:Perl不存在整形,全部是double类型.整形常量会被自动转换为浮点型. Perl数字字面量(直接量):+-和小数点是非必须的,e代表10的多少次方.例如:-1 ...

  2. Reference Counting GC (Part one)

    目录 引用计数法 计数器值的增减 new_obj()和update_ptr()函数 new_obj()生成对象 update_ptr()更新指针ptr,对计数器进行增减 优点 可即可回收垃圾 最大暂停 ...

  3. 03012_预处理对象executeQuery方法(实现数据库的查询)

    1.概述 (1)通过预处理对象的executeQuery方法,完成记录的select语句的执行: (2)操作格式统一如下: ①注册驱动: ②获取连接: ③获取预处理对象: ④SQL语句占位符设置实际参 ...

  4. Saltstack的API接口与调用方式

     saltstack看起来是成为一个大规模自己主动化运维和云计算管理的一个框架,类似于SDK,并非像puppet仅仅成为一个工具.基于良好设计的API和清楚的思路,让salt的二次开发变得非常easy ...

  5. [ES6] The Iterator Protocol

    The iterator protocol is used to define a standard way that an object produces a sequence of values. ...

  6. Codeforces Round #262 (Div. 2) 题解

    A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. Linux下Oracle的sqlplus中上下左右退格键无法使用

    一.配置yum源并安装readline* 配置本地yum 1.挂载光盘 mount /dev/cdrom /mnt/media 2,新建本地yun源的配置文件 vi /etc/yum.repos.d/ ...

  8. POJ 2104 K-th Number 静态主席树(裸

    题目链接:点击打开链接 题意: 给定n长的序列.q个询问 以下n个数字给出序列 每一个询问[l, r] k ,输出该区间中第k大的数 先建一个n个节点的空树.然后每次从后往前新建一棵树,依附原来的空树 ...

  9. [UnityUI]循环滑动列表

    效果图: 使用的是UGUI和DOTween 当中比較关键的是循环滑动和层次排序: 1.循环滑动:这里先如果显示五张图片.分别标记为0,1,2,3,4,那么当向左滑动时,序列就变为1,2,3,4,0,这 ...

  10. 关于MySQL utf8mb4 字符集中字符串长度的问题

    MySQL之前推出的utf8字符集中,一个汉字占3个字节,新的utf8mb4字符集中一个汉字占4个字节. 那么我们平时建表的时候输入的varchar=16这种,到底指的是字符长度还是字节长度? 如果是 ...