Python笔记从html中提取字段
来源:互联网 发布:三菱fx2n编程手册 编辑:程序博客网 时间:2024/06/07 10:36
def fun(): # url = 'http://quote.eastmoney.com/sh600010.html?from=BaiduAladdin' url_total = 'http://api.map.baidu.com/place/v2/search?q=景区&page_size=20&page_num=1®ion=白山市&scope=2&output=json&ak=秘钥' response = requests.get(url_total) url_total_html = response.text # print(html) # print(type(html),type(response),html[10:15]) # test1=html["total:[]"] # print(test1) # test2 ='total' # print(html.find(test2)) total_0=r'[\d]+' #提取所有数字,构成list result=re.compile(total_0) #将正则表达式编译成对象 其等价于result=re.compile(r'[\d]+') total_1=re.findall(result,url_total_html) # 匹配对象,其等价total_1=result.findall(url_total_html) # print('\n',total_0,type(total_0),len(total_0)) # print(total_1[1],type(total_0[1])) # print(int(total_1[1]),type(int(total_1[1]))) total_2=int(total_1[1])#提取后其为List,找到对应索引,将str转int print(total_2) #f = open('total—city', 'w') #f.writelines(total_2) #f.close()if __name__=='__main__': fun()
阅读全文
1 0
- Python笔记从html中提取字段
- Python 从MySQL 的表中提取字段名
- 从oracle字段中提取数字
- filebeat+elasticsearch从massage中提取字段
- 从HTML文档中提取链接
- ASP从HTML标签中提取中文
- JAVA从html中提取纯文本
- 用python从pdf中提取信息,转为txt或者html
- python从字符串中提取数字
- python: 从字符串中提取数字
- 从HTML代码中提取文字,去掉HTML的标记
- 从文本文件提取数据到数据库指定的字段中
- 从 sql server 2000 中提取字段说明文字
- iOS 从字符串中提取所需要的目标字段
- 从0开始,用python提取html链接
- 使用Python中的HTMLParser、cookielib抓取和解析网页、从HTML文档中提取链接、图像、文本、Cookies
- 使用Python中的HTMLParser、cookielib抓取和解析网页、从HTML文档中提取链接、图像、文本、Cookies(二)
- 使用Python中的HTMLParser、cookielib抓取和解析网页、从HTML文档中提取链接、图像、文本、Cookies .
- 设计模式之单例模式
- struts2学习笔记(一)
- Date的after()与before()方法的使用
- linux生成信任文件
- linux命令及VI编辑器基础
- Python笔记从html中提取字段
- 14《游戏化思维》-豆瓣评分7.0
- 阿里云 LNMP 环境配置
- fwrite和fread函数的用法小结
- 第一篇博文
- POJ 1940 Polygon Programming with Ease 笔记
- 用二分法查找循环递增序列 | Python
- JDBC(一)--JDBC核心API/JDBC工具类/Statement/PreparedStatement/CallableStatement
- 蛀牙--《设计模式---通往未来的很高的台阶之(二)》