- 博客(4)
- 收藏
- 关注
原创 爬虫实现POST请求
实现思路: 1·设置URL 2·构建表单数据,并使用urllib.prase.urlencode对数据进行编码处理 3·创建Request对象,参数包括URL和要传递的数据 4·使用add_header()添加头信息 5·使用urllib.request.urlopen()打开对应的Request对象,完成数据传递 6·后续处理如在http://iqianyue...
2018-03-10 17:37:06
5386
原创 re·正则表达式常见函数总结
1.re.match() 使用格式:re.match(pattern,string,flag) pattern代表正则表达式,string代表源字符,flag为可选参数,代表对应标志位(可以放置模式修正符等信息) 运行时会从string的起始位置开始匹配,如果不满足pattern则返回None,如果符合要求则返回匹配结果。2.re.search() 使用格式:re.sear...
2018-03-10 17:18:08
486
原创 urllib·打开DebugLog
import urllib.requesthttphd=urllib.request.HTTPHandler(debuglevel=1)httpshd=urllib.request.HYYPSHandler(debuglevel=1)opener=urllib.request.build_opener(httphd,httpshd) #创建全局默认opener对象
2018-03-10 17:07:27
244
原创 urllib·使用代理服务器
def use_proxy(proxy_addr,url): import urllib.request proxy=urllib.request.ProxyHandler({'http':proxy_addr}) #使用urllib.request.ProxyHandler()设置代理服务器信息 opener=urllib.request.build_opener(proxy...
2018-03-10 17:05:09
1790
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅