开通博客第一天
学习就如庖丁解牛,对事物的认识一般都是由浅入深、由表及里的过程,循序才能渐进。不管学习哪个领域的知识,如果你是初学者,那么建议按照教程的顺序阅读,不要跳跃,欲速则不达,揠苗也不见得能助长。
另外,强烈建议做好读书笔记,边看边记,边练习边思考,"学而不思则罔,思而不学则殆",比勤奋更重要的是思考的能力,不要傻学、死学。养成看书的好习惯,学习类的图书如果没能看成自己知识的积累,就是白读。一本书,可能看一遍是不够的,多次阅读,反复实践,才能印象深刻。本人曾翻烂 8 本《恋爱宝典》,但是从没向任何人表白,结果不言自明。实践是检验真理的唯一标准,实践出真知。
方法有了,贵在坚持。制定好自己的学习目标,设定奖惩,确定详细的时间进度表,开始行动!保持热情,坚定目标,做好计划,一步一个脚印,步步为营!
另附一个爬虫脚本,也是自己第一个比较满意的能成功运行的脚本,继续加油!
1 import requests 2 from lxml import etree 3 4 5 def headers(): 6 header = { 7 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 8 'X-Requested-With': 'XMLHttpRequest', 9 'User-Agent': 'Mozilla/5.0', 10 'Content-Type': 'text/html; charset=UTF-8' 11 } 12 return header 13 14 15 def read(): 16 url = 'http://www.qctsw.com/newtsw/tsPub.jsp' 17 header = headers() 18 response = requests.get(url, headers=header) 19 html = str(response.content, 'utf-8') 20 selector = etree.HTML(html) 21 return selector 22 23 24 def parse_0(): 25 selector = read() 26 content = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[1]/ul/li/text()') 27 return content 28 29 30 def parse_4(): 31 selector = read() 32 content1 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[1]/label/text()') 33 return content1 34 35 36 def parse_5(): 37 selector = read() 38 content2 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[2]/label/text()') 39 return content2 40 41 42 def parse_6(): 43 selector = read() 44 content3 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[3]/label/text()') 45 return content3 46 47 48 def parse_7(): 49 selector = read() 50 content4 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[4]/label/text()') 51 return content4 52 53 54 def parse_8(): 55 selector = read() 56 content5 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[5]/label/text()') 57 return content5 58 59 60 def parse_9(): 61 selector = read() 62 content6 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[6]/label/text()') 63 return content6 64 65 66 def parse_10(): 67 selector = read() 68 content7 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[7]/label/text()') 69 return content7 70 71 72 def parse_11(): 73 selector = read() 74 content8 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[8]/label/text()') 75 return content8 76 77 78 def parse_12(): 79 selector = read() 80 content9 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[1]/div/div[2]/ul/li[9]/label/text()') 81 return content9 82 83 84 def parse_1(): 85 selector = read() 86 content11 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li/span[1]/text()') 87 return content11 88 89 90 def parse_2(): 91 selector = read() 92 content12 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[2]/span[2]/label/text()') 93 item = [] 94 for i in range(1,15,2): 95 item.append(content12[i]) 96 return item 97 98 99 def parse_3(): 100 selector = read() 101 content13 = selector.xpath('//*[@id="myForm"]/div/ul[3]/li[3]/span[2]/label/text()') 102 item1 = [] 103 for i in range(1,15,2): 104 item1.append(content13[i]) 105 return item1 106 107 108 def save(): 109 content = parse_0() 110 content1 = parse_4() 111 content2 = parse_5() 112 content3 = parse_6() 113 content4 = parse_7() 114 content5 = parse_8() 115 content6 = parse_9() 116 content7 = parse_10() 117 content8 = parse_11() 118 content9 = parse_12() 119 content11 = parse_1() 120 item = parse_2() 121 item1 = parse_3() 122 dict = {content[0]:str(content1),content[1]:str(content2),content[2]:str(content3),content[3]:str(content4),content[4]:str(content5),content[5]:str(content6),content[6]:str(content7),content[7]:str(content8),content[8]:str(content9)} 123 dict1 = {content11[0]:str(content),content11[1]:str(item),content11[2]:str(item1)} 124 return print(dict,dict1) 125 126 127 def start(): 128 save() 129 130 131 if __name__ == '__main__': 132 start()