文章标题
来源:互联网 发布:北京设计软件培训班 编辑:程序博客网 时间:2024/05/14 20:09
使用到的python库:os。
关于OS库的介绍:
http://www.cnblogs.com/BeginMan/p/3327291.html
要注意的问题:
1.Slash(/)。
2.python中的file会自动创建,如果有同名则覆盖;
而文件夹需要显式地创建:os.makedirs(directory)
for link in links: if link["src"].startswith("http://www."): page="http://"+link["src"][11:] elif link["src"].startswith("http://"): page=link["src"] elif link["src"].startswith("www."): page="http://"+link["src"][4:] else: page="http://pythonscraping.com"+link["src"] if "http://pythonscraping.com" not in page: page=None if page is not None: print(page) path=page.replace("http://pythonscraping.com","") path="download"+path print(path) if "jpg" in path: directory=os.path.dirname(path) if not os.path.exists(directory): os.makedirs(directory) print(directory) urlretrieve(page,path)
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- Android API Guides---Advanced RenderScript
- windbg 查看符号文件有没有加载进windbg
- css样式选择器的种类及区别
- ORA-00205
- 杭电5665 Lucky
- 文章标题
- 优雅的实现Activiti动态调整流程(自由跳转、前进、后退、分裂、前加签、后加签等),含范例代码!
- java实现冒泡排序
- Android Binder设计与实现 - 实现篇
- MySQL函数
- objc_setAssociatedObject关联
- iOS开发工具箱[001]:可自动撑高的文字输入框
- Nginx教程(一) Nginx入门教程
- 继承FragmentActivity和Activity的区别.