d语言-下载网页,通过正则抓取对应的数据
2016-03-08 00:00
232 查看
摘要: d语言-下载网页,通过正则抓取对应的数据
---我的博客http://my.oschina.net/u/218155/blog?fromerr=SwOkb7Sw fllow me
std.net.curl
d语言的网路curl库,提供更高级的服务。
依赖 libcurl。[std.net.curl模块详细介绍地址](https://dlang.org/phobos/std_net_curl.html)
依赖于对libcurl的封装,提供一系列的高级方法哦。
download upload get post put del options trace connect byLine byChunk byLineAsync byChunkAsync
我们这里用到了get
std.regex
d语言的正则库
match matchAll等
std.conv
可以使用!to(xxx)方法 用于类型转换
代码如下
---我的博客http://my.oschina.net/u/218155/blog?fromerr=SwOkb7Sw fllow me
std.net.curl
d语言的网路curl库,提供更高级的服务。
依赖 libcurl。[std.net.curl模块详细介绍地址](https://dlang.org/phobos/std_net_curl.html)
依赖于对libcurl的封装,提供一系列的高级方法哦。
download upload get post put del options trace connect byLine byChunk byLineAsync byChunkAsync
我们这里用到了get
std.regex
d语言的正则库
match matchAll等
std.conv
可以使用!to(xxx)方法 用于类型转换
代码如下
import std.net.curl, std.stdio; import std.regex; import std.conv; void main() { //fech data auto url = "http://novel.hongxiu.com/a/263958/"; auto content = cast(string) get(url); //regex data auto r = regex(r"http://w.hongxiu.com/(\d+)/index.html"); auto match_arr = matchFirst(content,r); int s_bid = 0; if(!match_arr.empty){ auto s_b = match_arr[1]; s_bid = to!int(s_b); } writeln(s_bid); }
相关文章推荐
- 编程界主流脚本编程语言的比较和选择
- 什么是Perl?编程语言Perl详细介绍
- 编程语言里的静态、动态、强类型、弱类型等概念介绍
- 编程趣事:当下流行编程语言的”讨厌”程度排行榜
- 一张图告诉你计算机编程语言的发展历史
- 解析thinkphp中的M()与D()方法的区别
- 程序员必看2008编程语言走势解盘
- 24种编程语言的Hello World程序
- 256种编程语言大汇总
- 编程语言JavaScript简介
- 学编程选什么语言好?是PHP、Python还是Ruby?
- 编程语言Python的发展史
- Python编程语言的35个与众不同之处(语言特征和使用技巧)
- Python 与 Javascript 之比较
- 不要和一种编程语言厮守终生:为工作正确选择
- 2015年值得学习的15种编程语言
- Go 语言:Google 的新编程语言
- IE的CSS相关的BUG
- 类型的本质和函数式实现
- 程序员的相关笑话(二)