【ibrowse http请求】
本帖最后由 shijiang1130 于 2015-11-21 23:11 编辑https://github.com/cmullaparthi/ibrowse
下载到你安装erlang的lib目录,1> application:start(ibrowse).
ok
4> ibrowse:send_req("http://www.baidu.com",[],get).
{ok,"200",
[{"Date","Sat, 21 Nov 2015 15:08:56 GMT"},
{"Content-Type","text/html"},
{"Content-Length","14613"},
{"Last-Modified","Wed, 03 Sep 2014 02:48:32 GMT"},
{"Connection","Keep-Alive"},
{"Vary","Accept-Encoding"},
{"Set-Cookie",
"BAIDUID=1CE85A2CEB532E84561A842237CA23A1:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"},
{"Set-Cookie",
"BIDUPSID=1CE85A2CEB532E84561A842237CA23A1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"},
{"Set-Cookie",
"PSTM=1448118536; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com"},
{"Set-Cookie","BDSVRTM=0; path=/"},
{"P3P","CP=\" OTI DSP COR IVA OUR IND COM \""},
{"Server","BWS/1.1"},
{"X-UA-Compatible","IE=Edge,chrome=1"},
{"Pragma","no-cache"},
{"Cache-control","no-cache"},
{"BDPAGETYPE","1"},
{"BDQID","0xfdf08a62000d1e0f"},
{"BDUSERID","0"},
{"Accept-Ranges","bytes"}],
[60,33,68,79,67,84,89,80,69,32,104,116,109,108,62,60,33,45,
45,83,84,65,84,85,83|...]}
5> Current Version: 4.2,直接下载这个编译好了的 它的TIMEOUT功能5> ibrowse:send_req("http://www.google.com",[],get,[],[],5000).
{ok,"302",
[{"Location",
"http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/%3Fgws_rd%3Dcr&ust=1448118863457835&usg=AFQjCNHx_7z6aqNCySJ_5PGnDTHJAlotqQ"},
{"Cache-Control","private"},
{"Content-Type","text/html; charset=UTF-8"},
{"Date","Sat, 21 Nov 2015 15:13:53 GMT"},
{"Server","gws"},
{"Content-Length","390"},
{"X-XSS-Protection","1; mode=block"},
{"X-Frame-Options","SAMEORIGIN"},
{"Set-Cookie",
"PREF=ID=1111111111111111:FF=0:NW=1:TM=1448118833:LM=1448118833:V=1:S=iE6lT59UG4U_hiom; expires=Thu, 31-Dec-2015 16:02:17 GMT; path=/; domain=.google.com"}],
"<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>302 Moved</TITLE></HEAD><BODY>\n<H1>302 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/%3Fgws_rd%3Dcr&ust=1448118863457835&usg=AFQjCNHx_7z6aqNCySJ_5PGnDTHJAlotqQ\">here</A>.\r\n</BODY></HTML>\r\n"}
6> ibrowse:send_req("http://www.google.com.hk",[],get,[],[],5000).
{error,req_timedout}
7> 异步请求10> ibrowse:send_req("http://www.baidu.com",[],get,[],[{stream_to,self()}]).
{ibrowse_req_id,-576460752303423437}
11>
页:
[1]