Python爬取3gpp R13协议
来源:互联网 发布:js时间戳转换为日期 编辑:程序博客网 时间:2024/05/24 07:25
工作中需要用到3gpp,各个系列用到的文件比较多,一个一个找又很麻烦。
干脆一不做二不休,全部打包!
平台:
Python3.5
直接上代码:
'''Python爬取3gpp协议R13版本所有文本将爬取的.zip文件按照3gpp网站http://www.3gpp.org/ftp/Specs/latest/Rel-13/内容进行自动分类。'''import urllib.request #获取URL文本import re,os #正则表达式匹配URL及.zip文件#设置起始URL.start_url = 'http://www.3gpp.org/ftp/Specs/latest/Rel-13/'#爬取网页内容保存到conentNet字符串中.with urllib.request.urlopen(start_url) as f: contentNet = f.read().decode('utf-8')#解析R13协议的所有系列:['/21_series','/22_series'.....'/55_series']list_Parser = re.findall(r'/[0-9]{2}.series',contentNet)#解析得到所有.zip文件的URL绝对地址list_path = []list_File = []list_Zip = []list_URL = []for i in list_Parser: i2 = i.strip('/') list_File.append(i2)for i in list_Parser: i2 = start_url+i.strip('/') list_path.append(i2)for i in list_path: with urllib.request.urlopen(i) as f: contentURL = f.read().decode('utf-8') list_Zip = re.findall(r'/[0-9]{5}.*?\.zip',contentURL) for m_zip in list_Zip: i2 = i+m_zip list_URL.append(i2)#建立series文件夹,如果文件不存在的话。for i in list_File: if not os.path.exists(i): os.makedirs(i)#下载所有.zip文件到指定的文件夹...for i in list_URL: os.chdir('E:\\Code\\python\\3gppData\\' + i.split('/')[-2]) #支持断点续传; if os.path.exists(i.split('/')[-1]): continue else: urllib.request.urlretrieve(i, i.split('/')[-1]) #TODO 导入线程模块,开启多线程解决单线程下载慢问题。
阅读全文
1 0
- Python爬取3gpp R13协议
- 3gpp协议网址
- 3GPP 协议导读
- 3GPP协议下载
- 缩写. 3gpp 协议.
- 3GPP协议下载网址
- 3gpp协议下载地址
- 3GPP协议下载网址
- R13 LAA协议翻译
- 3GPP协议官方下载地址
- 3GPP协议官方下载地址
- 3GPP TS 0710 MUX协议
- 3GPP协议下载网址说明
- 3GPP协议官方下载地址
- 3GPP TS 0710 MUX协议
- 3GPP协议学习以及分享
- 3GPP协议官方下载地址
- 3GPP TS协议系列总结
- poj-2533 最长递增子序列
- 极限编程价值观及最佳实践
- 开启MySQL的binlog日志
- Java 8——Optional泛型类
- oracle新建管理员用户
- Python爬取3gpp R13协议
- Set和Map数据结构
- Shiro集成Web
- 7. Reverse Integer
- 一些图论、网络流入门题总结、汇总
- Rss Feed是什么?
- 如何使用Framework7的图标icons
- 考研英语真题 阅读理解翻译及笔记——1994/section 2/text3
- 80个自我提升的网站