爬虫实现POST请求 实现思路: 1·设置URL 2·构建表单数据,并使用urllib.prase.urlencode对数据进行编码处理 3·创建Request对象,参数包括URL和要传递的数据 4·使用add_header()添加头信息 5·使用urllib.request.urlopen()打开对应的Request对象,完成数据传递 6·后续处理如在http://iqianyue...
re·正则表达式常见函数总结 1.re.match() 使用格式:re.match(pattern,string,flag) pattern代表正则表达式,string代表源字符,flag为可选参数,代表对应标志位(可以放置模式修正符等信息) 运行时会从string的起始位置开始匹配,如果不满足pattern则返回None,如果符合要求则返回匹配结果。2.re.search() 使用格式:re.sear...
urllib·打开DebugLog import urllib.requesthttphd=urllib.request.HTTPHandler(debuglevel=1)httpshd=urllib.request.HYYPSHandler(debuglevel=1)opener=urllib.request.build_opener(httphd,httpshd) #创建全局默认opener对象
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...