随笔分类 - python爬虫
摘要:# coding=utf-8import requestsfrom lxml import etreea='https://www.dytt8.net'headers={ 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb
阅读全文
摘要:\s 匹配任意空白字符\t\n\r\f \S 匹配任意非空白字符 \d 匹配任意数字[0_9] ^ 匹配一行字符串开头 $ 匹配一行字符串结尾 . 匹配任意字符 except \n * 匹配0次货多次前面的内容 + 匹配1次或多次前面的内容 ? 匹配0次或1次前面的内容 非贪婪 a|b 匹配a或者b
阅读全文
摘要:说明python不能被调用,需要为他制定正确的路径。0=0(win10想要打开任何东西,左下角搜索框) 1.打开 python,输入import os 输入os.getcwd,得到路径。 2.打开 编辑系统环境变量选择高级-系统变量-环境变量-双击Path-编辑-改成1的地址-确定
阅读全文
摘要:1.urlopen from urllib import request resp=request urlopen('http://www.baidu.com') print(resp.read()) 2.urlretrieve from urllib import request request
阅读全文
摘要:1.HTTPS是HTTP的加密版 2.URL详解:例如:scheme://host:port/path/query_string..........anchor (1)scheme 访问的协议,一般为https,或http以及ftp等 (2)host 主机名域名,比如www.baidu.com (3
阅读全文
摘要:如图所示,爬去网站的url时,深度优先按照这个顺序爬取 利用递归实现树的广度优先遍历 A B D E I C F G H(递归实现) def depth-tree(tree-code); if tree-node is not None; print (tree-note.-data) if tre
阅读全文