pyhon/numpy/pandas(十二)-xml
来源:互联网 发布:js点击按钮打开新窗口 编辑:程序博客网 时间:2024/06/07 05:28
from lxml.html import parseimport urllib.requestparsed=parse(urllib.request.urlopen('http://finance.sina.com.cn/stock/'))doc=parsed.getroot()print (doc)<Element html at 0x54db9f8>
links=doc.findall('.//a')links[:3][<Element a at 0x55fe5e8>, <Element a at 0x55fe868>, <Element a at 0x55fe6d8>]
urls=[lnk.get('href') for lnk in doc.findall('.//a')]urls[-10:]['http://corp.sina.com.cn/chn/', 'http://corp.sina.com.cn/eng/', 'http://emarketing.sina.com.cn/', 'http://www.sina.com.cn/contactus.html', 'http://corp.sina.com.cn/chn/sina_job.html', 'http://www.sina.com.cn/intro/lawfirm.shtml', 'http://english.sina.com', 'https://login.sina.com.cn/signup/signup.php', 'http://help.sina.com.cn/', 'http://corp.sina.com.cn/chn/copyright.html']
tables=doc.findall('.//table')call=tables[1]rows=call.findall('.//tr')def _unpack(row,kind='td'): elts=row.findall('.//%s' % kind) return [val.text_content() for val in elts]_unpack(rows[0],kind='td')['行业涨幅', '行业跌幅', '行业流入', '行业流出']
0 0
- pyhon/numpy/pandas(十二)-xml
- python/pandas/numpy(十二)数据加载、存储与文件格式
- pandas |numpy
- NumPy、SciPy和Pandas
- Numpy与Pandas排序
- Numpy与Pandas
- pandas numpy学习笔记
- python+pandas+scipy+numpy
- pandas IO numpy 矩阵
- pandas numpy常用函数
- Why Numpy & Pandas?
- Python之Numpy之pandas
- NumPy.npy与pandas DataFrame
- numpy,scipy,pandas 和 matplotlib
- pandas和numpy的使用
- numpy、scipy、pandas、matplotlib了解
- pandas/numpy常用方法/属性
- 优达学城Numpy与Pandas笔记
- C++对象指针
- 1 - c_call_Python api
- Java开发—环境搭建之Eclipse中安装Maven
- MySQL · 答疑解惑 · MySQL 锁问题最佳实践
- 创建OpenCV-Android库
- pyhon/numpy/pandas(十二)-xml
- 关于storyboard 的segue返回方法
- 基于内容的相似图片检索
- ACMU—1160
- JavaScript笔记之第六天
- 1211. 商人的宣传
- CSS3笔记之第四天
- 【ife】任务二十二:JavaScript和树(一)
- 常见的运行时异常(RuntimeException) 和 复制中的异常处理