当前位置: 首页 > news >正文

建站工具wordpress外贸网站推广招聘

建站工具wordpress,外贸网站推广招聘,开发公司五证包括什么,织梦做网站想用C语言写个采集程序#xff0c;涉及到http相关的东西#xff0c;找了找#xff0c;有现成的libghttp库。 libghttp库的官方网址google一下第一条结果一般就是的#xff1a;http://lfs.linuxsir.org/htdocs/blfscvs/gnome/libghttp.html 将源码包下载下来#xff0c;进…想用C语言写个采集程序涉及到http相关的东西找了找有现成的libghttp库。 libghttp库的官方网址google一下第一条结果一般就是的http://lfs.linuxsir.org/htdocs/blfscvs/gnome/libghttp.html 将源码包下载下来进入例行安装流程 1、解压 # tar -xzvf libghttp-1.0.9.tar.gz # cd libghttp-1.0.9 2、安装 ./configure make make install 安装过种中小插曲 在执行./configure命令的时候报错 checking host system type... Invalid configuration x86_64-unknown-linux-gnu: machine x86_64-unknown not recognizedchecking build system type... Invalid configuration x86_64-unknown-linux-gnu: machine x86_64-unknown not recognizedchecking for ranlib... ranlib checking for ld used by GCC... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes updating cache ./config.cache ltconfig: you must specify a host type if you use --no-verify Try ltconfig --help for more information. configure: error: libtool configure failed 听说在32位操作系统上一般不会有这样的错误在64位系统上比较常见原因是软件自身的config.guess和config.sub文件有问题从系统中复制这两个文件到软件目录覆盖一下重新./configure就可以了(如果不知道这两个文件在哪里用find查找一下就OK了) # 首先查找一下config.guess和config.sub文件的目录 find / -name config.guess find / -name config.sub# 将查找出来的文件随便选择一个覆盖到软件目录 cp /usr/share/automake-1.11/config.guess . cp /usr/share/automake-1.11/config.sub . 下面是用libghttp搞了一个测试代码成功编译和运行证明libhttp安装成功啦 #includelibghttp.h #includesthio.hmain() {// This is the http request objectghttp_request *request NULL;// Allocate a new empty request objectrequest ghttp_request_new();// Set the URI for the request objectghttp_set_uri(request, http://www.phpjiayuan.com/);// Close the connection after you are done.ghttp_set_header(request, http_hdr_Connection, close);// Prepare the connectionghttp_prepare(request);// Process the requestghttp_process(request);// Write out the body. Note that the body of the request may not be null terminated so we have to be careful of the length. fwrite(ghttp_get_body(request), ghttp_get_body_len(request), 1, stdout);// Destroy the request. This closes any file descriptors that may be open and will free any memory associated with the reque st. ghttp_request_destroy(request); } 另一个网络上的实例 netutil.h /* * File: netutil.h * Author: Administrator * * Created on 2014年9月2日, 下午3:51 */ #ifndef NETUTIL_H #define NETUTIL_H #ifdef __cplusplus extern C { #endif int isFileExist(char * savePath); int download(char *uri, char *savePath) ; //result地址参数传递 int netGet(char* url, char* params, int timeout, char **result, int result_len) ; int netPost(char* uri, char* params, int timeout, char **result, int result_len) ; #ifdef __cplusplus } #endif #endif /* NETUTIL_H */ netutil.c #include ghttp.h #include http_hdrs.h #include stdio.h #include string.h #include stdlib.h #include io.h #include unistd.h #define GET_ARRAY_LEN(array,len) {len (sizeof(array) / sizeof(array[0]));} int isFileExist(char * savePath) { if (!access(savePath, F_OK)) { return 1; } else { return 0; } } //http://www.elesos.com/index.php?titleLibghttp库使用指南 int download(char *uri, char *savePath) { ghttp_request *request NULL; ghttp_status status; FILE * pFile; char *buf; int bytes_read; int size; if(!isFileExist(savePath)) { printf(savePath not exist ); } pFile fopen(savePath, wb); request ghttp_request_new(); if (ghttp_set_uri(request, uri) -1) return -1; if (ghttp_set_type(request, ghttp_type_get) -1)//get return -1; ghttp_prepare(request); status ghttp_process(request); if (status ghttp_error) return -1; printf(Status code - %d\n, ghttp_status_code(request)); buf ghttp_get_body(request); bytes_read ghttp_get_body_len(request); //size strlen(buf); //size bytes_read //这里是错误的,当返回的数据为文本时,strlen的长度是正确,二进制数据如图片/apk时的长度是错误的。 size bytes_read; //size ! bytes_read printf(buf :%s \n size :%d \n , buf,size); fwrite(buf, 1, size, pFile); fclose(pFile); ghttp_clean(request); ghttp_request_destroy(request); return 0; } //result地址参数传递 int netGet(char* url, char* params, int timeout, char **result, int result_len) { ghttp_request *request NULL; request ghttp_request_new(); if(params!NULLstrlen(params)0) { char tmp[1024]; strcpy(tmp,url); if(strchr(tmp, ?) NULL)//url不存在 { strcat(tmp,?) ; } strcat(tmp,params) ; printf(%s\n,tmp); ghttp_set_uri(request, tmp); }else{ ghttp_set_uri(request, url); } ghttp_set_type(request, ghttp_type_get); //get方法 ghttp_set_header(request, http_hdr_Connection, close); char timeout_str[10]; sprintf(timeout_str, %d, timeout); ghttp_set_header(request, http_hdr_Timeout, timeout_str); ghttp_prepare(request); ghttp_process(request); *result ghttp_get_body(request); result_len ghttp_get_body_len(request); ghttp_request_destroy(request); return 0; } int netPost(char* uri, char* params, int timeout, char **result, int result_len) { char szVal[1024]; ghttp_request *request NULL; ghttp_status status; int len; printf(%s\n, params); //test request ghttp_request_new(); if (ghttp_set_uri(request, uri) -1) return -1; if (ghttp_set_type(request, ghttp_type_post) -1) //post return -1; ghttp_set_header(request, http_hdr_Content_Type,application/x-www-form-urlencoded); char timeout_str[10]; sprintf(timeout_str, %d, timeout); ghttp_set_header(request, http_hdr_Timeout, timeout_str); //ghttp_set_sync(request, ghttp_sync); //set sync len strlen(params); ghttp_set_body(request, params, len); // ghttp_prepare(request); status ghttp_process(request); if (status ghttp_error) return -1; *result ghttp_get_body(request); //test result_lenghttp_get_body_len(request); ghttp_clean(request); return 0; } main.c #include stdlib.h #include netutil.h int main(int argc, char *argv[]) { char *result; int len; result(char*)malloc(sizeof(char*)*8096); memset(result, 0, sizeof(char*)*8096); char param[2048] lanjavaPOSTDATA15fghttp; netPost(http://127.0.0.1:8080/server/index.do,param, 5000, result, len); printf(%s\n%d\n, result, len); netGet(http://127.0.0.1:8080/server/index.do?heheyy,param, 5000, result, len); printf(%s\n%d\n, result, len); download(http://www.baidu.com/,test//fuck.html); return 0; } 转自http://www.phpjiayuan.com/109/270.html 转自:http://blog.csdn.net/earbao/article/details/39007549
http://www.huolong8.cn/news/66846/

相关文章:

  • 微信导航网站有用吗网站运营维护中需要用到什么服务器
  • 做网站去哪个公司好大连seo推广外包
  • 网站图片什么格式一个thinkphp搭建的微网站
  • 网站标题应怎设置设计一个商务网站
  • 广州站是哪个站网店美工具体要求
  • 视频库网站建设安阳百度网站制作多少钱
  • 天津市网站制作公司wordpress首页怎么进入
  • 免费企业网站建设单位三水网站制作
  • 做一个网站花多少钱电商平台投诉电话
  • 英文网站的外部链接 建设鲅鱼圈网站制作
  • 婚纱摄影网站模板下载网站开发最快框架
  • 莱州网站建设公司电话上海专业做网站公司有哪些
  • 长沙医考网站建设公司成都网站建设金网科技
  • 昌平做网站公司网站建设设计有哪些
  • 网站做以后怎么修改网站内容汕头网站设计怎么做
  • 广 做网站蓝光电影下载最美情侣视频免费观看完整版高清
  • 移动网站开发实训报告开跨境电商的店需要多少钱
  • 网站专业销售团队介绍加密网站
  • 甜水园网站建设wordpress主题站模板下载
  • 空投糖果网站开发重庆低价网站建设
  • 对运营网站有什么见解楚雄seo
  • 云南哪几个建网站公司中国制造网外贸站
  • 北京网站设计公司兴田德润怎么样网站页面文案
  • 怎么制作网站来赚钱空间域名
  • 手机网站建设怎么样长春移动网站建设
  • 整站下载器 做网站地图seo技巧课程
  • 怎么提高网站浏览量山西省建设厅网站打不开
  • 众筹网站开发分析报告百度做网站骗人到哪里去投诉
  • uemo网站源码专业网站开发公司
  • 手机网站居中显示wordpress的文件权限