- 论坛徽章:
- 0
|
8可用积分
本帖最后由 oopul 于 2012-09-06 23:55 编辑
要求跨平台(Windows/Linux) (如能同时支持Mac OSX / BSD最好)
如页面需要跳转,并跳转下载,其他情况返回错误信息HTTP代码(403/304/302/301/500/503/504/501)之类
程序样例
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifdef WIN32
#include <winsock2.h>
#pragma comment( lib , "ws2_32.lib")
#else
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
int create_dir(char *url)
{
//需要您补充
}
int download(char *url,char *dir)
{
//需要您补充
}
int main(int argc,char** argv)
{
if(argc!=3)
{
printf("usage: %s http://www.baidu.com/index.php C:/test/test1/test2/index.php",argv[0]);
return 0;
}
return download(argv[1],argv[2]);
}
|
|