![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
qq_19408603
这个作者很懒,什么都没留下…
展开
-
python装饰器
第一种形式 def decorator(fun): logging.warn("before") fun() logging.warn("after") return fun 使用 语法糖 @decorator def fun(): print("ok"); 上述其实等价于 fun = decorator(fun)原创 2017-07-15 09:38:47 · 186 阅读 · 0 评论 -
python抓取文件批量下载,单目录的情况下
使用python批量下载文件: import urllib import sys import BeautifulSoup import re print "downloading with urllib" url = 'http://139.196.233.65/js' content = urllib.urlopen(url).read() #reg = r'(?:hr原创 2017-08-19 16:17:11 · 447 阅读 · 0 评论 -
python爬虫下载网站所有文件
核心思路是使用正则表达式对网页的html5中的路径名和文件名进行抓取, 然后对路径继续进行同样的抓取,用递归的方式进行搜索。最后把网站上的内容文件全部下载下来 import urllib import sys import BeautifulSoup import re import os path = [] def extract(url):原创 2017-08-19 16:58:21 · 8463 阅读 · 0 评论