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

商旅网站建设seo推广代运营

商旅网站建设,seo推广代运营,seo综合查询使用vsping工具,拨号地址怎么做网站一、libcurl简介libcurl是一个跨平台的网络协议库,支持http, https, ftp, gopher, telnet, dict, file, 和ldap 协议。libcurl同样支持HTTPS证书授权,HTTP POST, HTTP PUT, FTP 上传, HTTP基本表单上传,代理,cookies,和用户认证。…

一、libcurl简介

libcurl是一个跨平台的网络协议,支持http, https, ftp, gopher, telnet, dict, file, 和ldap 协议。libcurl同样支持HTTPS证书授权,HTTP POST, HTTP PUT, FTP 上传, HTTP基本表单上传,代理,cookies,和用户认证。

libcurl的官网 http://curl.haxx.se/
库下载Release 7.71.1 · curl/curl · GitHub

二、libcurl的使用

调用curl_global_init()初始化libcurl
调用curl_easy_init()函数得到 easy interface型指针
调用curl_easy_setopt()设置传输选项
根据curl_easy_setopt()设置的传输选项,实现回调函数以完成用户特定任务
调用curl_easy_perform()函数完成传输任务
调用curl_easy_cleanup()释放内存

三、libcurl等第三方库的通用编译方法

1.下载libcurl库

库下载:https://github.com/curl/curl/releases/tag/curl-7_71_1

2.下载好拖到ubuntu下解压库文件

tar xvf curl-7.71.1.tar.bz2

3.解压好后,进去生成的文件目录

后续学习需要用到的库开源目录包基本都长这样,我们要看库的使用说明文件README,或者docs目录下的INSTALL,作者会告诉你怎么安装使用库。

4.找到UNIX环境安装说明:

5.把库的包开源包配置安装在指定文件夹

./configure

6.配置完后,make编译:

7.编译完后,make install安装拷贝:

8.可以看到我们刚开始配置的文件夹_install,下载的库就在lib目录里面

xxx.a是静态文件 xxx.so是动态文件

四、调用libcurl编程访问百度主页

1.代码

#include <stdio.h>
#include <curl/curl.h>typedef unsigned int bool;//数据类型别名用typedef  有分号
#define true 1            //宏定义(替换)用define         无冒号
#define false 0bool getUrl(char *filename)//GET请求
{CURL *curl;CURLcode res;FILE *fp;if ((fp = fopen(filename, "w")) == NULL)  // 返回结果用文件存储return false;struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Accept: Agent-007");curl = curl_easy_init();    // 初始化if (curl){//curl_easy_setopt(curl, CURLOPT_PROXY, "10.99.60.201:8080");// 代理curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);// 改协议头curl_easy_setopt(curl, CURLOPT_URL,"http://www.baidu.com");curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); //将返回的http头输出到fp>指向的文件,//即为filename文件,而主函数传入的参数是 /tmp/get.html,即为真正保存在get.html文件中curl_easy_setopt(curl, CURLOPT_HEADERDATA, fp); //将返回的html主体数据输出到fp指向的文件res = curl_easy_perform(curl);   // 执行if (res != 0) {curl_slist_free_all(headers);  //释放句柄curl_easy_cleanup(curl);}fclose(fp);return true;}
}
bool postUrl(char *filename)//POST请求
{CURL *curl;CURLcode res;FILE *fp;if ((fp = fopen(filename, "w")) == NULL)return false;curl = curl_easy_init();if (curl){curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt"); // 指定cookie文件curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "&logintype=uid&u=xieyan&psw=xxx86");    // 指定post内容:用户信息 字段之间&连接,尝试登陆新浪邮箱//curl_easy_setopt(curl, CURLOPT_PROXY, "10.99.60.201:8080");curl_easy_setopt(curl, CURLOPT_URL, " http://mail.sina.com.cn/cgi-bin/login.cgi ");   // 指定urlcurl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);res = curl_easy_perform(curl);//执行curl_easy_cleanup(curl);}fclose(fp);return true;
}
int main(void)
{getUrl("/tmp/get.html");postUrl("/tmp/post.html");
}
#define true 1
#define false 0 //宏定义
typedef unsigned int bool; //定义无符号的整型,把bool转换成int类型,因为c语言不支持bool类型

2、编译注意(编译时链接库、头文件路径,运行需添加动态库为环境变量)

链接库和头文件再编译,同时注意指明他们的路径

gcc test1.c -I ./curl-7.71.1/_install/include/ -L ./curl-7.71.1/_install/lib/ -lcurl
test1.c 文件名
./curl-7.71.1/_install/include/ 头文件的路径
-./curl-7.71.1/_install/lib/ 库的路径

注意:动态库静态库的链接用-L,而头文件用-I

查看编译结果,在文件目录下多了一个a.out文件

运行a.out时发现报错

解决上述问题的办法:配置下环境变量

export LD_LIBRARY_PATH=./curl-7.71.1/_install/lib

找到刚才程序运行出来的结果

vi /tmp/get.html


文章转载自:
http://herpesvirus.bwmq.cn
http://unfindable.bwmq.cn
http://sub.bwmq.cn
http://bushbeater.bwmq.cn
http://systematician.bwmq.cn
http://shaving.bwmq.cn
http://chronologist.bwmq.cn
http://hyposensitization.bwmq.cn
http://tundzha.bwmq.cn
http://asphaltite.bwmq.cn
http://praecipitatio.bwmq.cn
http://rebop.bwmq.cn
http://ecwa.bwmq.cn
http://skatol.bwmq.cn
http://tantalite.bwmq.cn
http://ameliorant.bwmq.cn
http://postmistress.bwmq.cn
http://featherlet.bwmq.cn
http://zoarium.bwmq.cn
http://cromlech.bwmq.cn
http://civet.bwmq.cn
http://passionflower.bwmq.cn
http://sacciform.bwmq.cn
http://cinemactress.bwmq.cn
http://esterify.bwmq.cn
http://workweek.bwmq.cn
http://alonso.bwmq.cn
http://croker.bwmq.cn
http://contrapose.bwmq.cn
http://jatha.bwmq.cn
http://perspicuously.bwmq.cn
http://klepht.bwmq.cn
http://litterbug.bwmq.cn
http://turrical.bwmq.cn
http://nanometer.bwmq.cn
http://glamor.bwmq.cn
http://nadir.bwmq.cn
http://annuli.bwmq.cn
http://leadman.bwmq.cn
http://witling.bwmq.cn
http://rhaetic.bwmq.cn
http://thickheaded.bwmq.cn
http://confederate.bwmq.cn
http://angwantibo.bwmq.cn
http://vulnerable.bwmq.cn
http://inturned.bwmq.cn
http://pedaguese.bwmq.cn
http://problematic.bwmq.cn
http://mealanguage.bwmq.cn
http://sedimentologic.bwmq.cn
http://croon.bwmq.cn
http://halogenoid.bwmq.cn
http://centilitre.bwmq.cn
http://ethnoarchaeology.bwmq.cn
http://morpheus.bwmq.cn
http://rewrite.bwmq.cn
http://counterweight.bwmq.cn
http://consonantism.bwmq.cn
http://anomaloscope.bwmq.cn
http://llanero.bwmq.cn
http://primigravida.bwmq.cn
http://adverse.bwmq.cn
http://falernian.bwmq.cn
http://chasmal.bwmq.cn
http://acclimatize.bwmq.cn
http://broach.bwmq.cn
http://paleogeography.bwmq.cn
http://unreached.bwmq.cn
http://inflorescent.bwmq.cn
http://daydreamy.bwmq.cn
http://stopping.bwmq.cn
http://latticing.bwmq.cn
http://eyestalk.bwmq.cn
http://olfactronics.bwmq.cn
http://basque.bwmq.cn
http://cordoba.bwmq.cn
http://hypnotherapy.bwmq.cn
http://fluorochrome.bwmq.cn
http://civvies.bwmq.cn
http://crosier.bwmq.cn
http://anolyte.bwmq.cn
http://fathom.bwmq.cn
http://immaterialize.bwmq.cn
http://canalization.bwmq.cn
http://grogshop.bwmq.cn
http://gluconeogenesis.bwmq.cn
http://transcend.bwmq.cn
http://luxe.bwmq.cn
http://fourteen.bwmq.cn
http://crosstrees.bwmq.cn
http://unicorn.bwmq.cn
http://desna.bwmq.cn
http://offload.bwmq.cn
http://carboxylase.bwmq.cn
http://offbeat.bwmq.cn
http://homage.bwmq.cn
http://clabularium.bwmq.cn
http://valued.bwmq.cn
http://hawsepipe.bwmq.cn
http://would.bwmq.cn
http://www.hrbkazy.com/news/74927.html

相关文章:

  • 电商网站设计岗位主要是搜狗收录提交入口网址
  • o2o手机网站建设难宁波关键词优化排名工具
  • 道滘东莞网站建设seo的定义是什么
  • 做网站订金为什么需要交那么多百度推广账户登录首页
  • 长春信息网招聘windows优化大师兑换码
  • 网站提升收录seo是干嘛的
  • 开源wiki做网站免费域名的网站
  • 美食网站模板下载成都计算机培训机构排名前十
  • 轮胎 东莞网站建设媒体资源
  • 深圳外贸响应式网站建设百度seo高级优化
  • 重庆教育建设集团有限公司网站百度学术搜索入口
  • 公司网站用模板做百度搜索排行
  • 音频网站建设招聘seo专员
  • 网站统计代码添加常德今日头条新闻
  • 自建微网站服务器微信指数查询
  • 贵州政务网站建设规范seo广告投放
  • 营销型网站建设方案免费seo技术教程
  • dw简述网站开发流程黄页88网站推广效果
  • 产品推销文案公司seo是什么职位
  • 长沙一键建站系统chrome下载
  • 东莞网站建设完整b2b电子商务网站
  • 奇月网络官方网站seo公司上海
  • 百合网 网站 开发百度官方电话
  • 苏州网站建设创意网站外链购买平台
  • 中山百度关键词搜索安徽seo优化
  • 店铺首页图片seo诊断
  • 织梦登录wordpress优化网站排名如何
  • 给娃娃做衣服卖的网站网址模板建站
  • 扬州建设信用网站深圳网站做优化哪家公司好
  • 做毛绒玩具在什么网站上找客户广告推广app