http://bbs.youkuaiyun.com/topics/390242602
1.使用ghttp之类的library,发送http请求获取。
2.调用外部程序,比如curl获取。例子,调用curl获取
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include <stdio.h>
#include <stdlib.h>
int
main(
void
)
{
FILE
*fp;
char
buf[BUFSIZ];
if
(NULL != (fp = popen(
"curl http://www.baidu.com"
,
"r"
)))
fread
(buf, BUFSIZ, 1, fp);
else
{
fprintf
(stderr,
"popen error...\n"
);
exit
(1);
}
printf
(
"%s\n"
, buf);
pclose(fp);
return
0;
}
|
-------------------------------------------------------------------
做实验用脚本最快, 你要用C就用libcurl。
-------------------------------------------------------------------
对CURL的一些研究
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=586014-------------------------------------------------------------------