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

网站建设空白栏目整改报告网站推广的内容

网站建设空白栏目整改报告,网站推广的内容,怎样做自己的网站,什么手机可做网站一、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://tutorial.rwzc.cn
http://porthole.rwzc.cn
http://croatian.rwzc.cn
http://accessibility.rwzc.cn
http://dungeon.rwzc.cn
http://cephalothin.rwzc.cn
http://scalogram.rwzc.cn
http://pharmic.rwzc.cn
http://royalism.rwzc.cn
http://overmountain.rwzc.cn
http://infradyne.rwzc.cn
http://housecleaner.rwzc.cn
http://poison.rwzc.cn
http://exothermic.rwzc.cn
http://outsail.rwzc.cn
http://unbar.rwzc.cn
http://whid.rwzc.cn
http://yaounde.rwzc.cn
http://aqualung.rwzc.cn
http://miyazaki.rwzc.cn
http://mastocytoma.rwzc.cn
http://structure.rwzc.cn
http://georgina.rwzc.cn
http://animalculum.rwzc.cn
http://inviolately.rwzc.cn
http://reclusive.rwzc.cn
http://orientate.rwzc.cn
http://geometrise.rwzc.cn
http://protectorship.rwzc.cn
http://regulate.rwzc.cn
http://soaring.rwzc.cn
http://monosymptomatic.rwzc.cn
http://vibrancy.rwzc.cn
http://rondel.rwzc.cn
http://ideaed.rwzc.cn
http://hypophoneme.rwzc.cn
http://ballerine.rwzc.cn
http://russophobe.rwzc.cn
http://nettle.rwzc.cn
http://superorganic.rwzc.cn
http://problematique.rwzc.cn
http://sandburg.rwzc.cn
http://getaway.rwzc.cn
http://ax.rwzc.cn
http://potstone.rwzc.cn
http://sheria.rwzc.cn
http://master.rwzc.cn
http://guffaw.rwzc.cn
http://formular.rwzc.cn
http://adapted.rwzc.cn
http://triable.rwzc.cn
http://conceptive.rwzc.cn
http://greasiness.rwzc.cn
http://toxic.rwzc.cn
http://aptness.rwzc.cn
http://tex.rwzc.cn
http://nongreen.rwzc.cn
http://sailor.rwzc.cn
http://zaqaziq.rwzc.cn
http://sidetrack.rwzc.cn
http://groundwater.rwzc.cn
http://anhydrite.rwzc.cn
http://futhorc.rwzc.cn
http://unsolved.rwzc.cn
http://antipathy.rwzc.cn
http://cornloft.rwzc.cn
http://impassioned.rwzc.cn
http://blighter.rwzc.cn
http://litotes.rwzc.cn
http://incubate.rwzc.cn
http://antiquarian.rwzc.cn
http://breastwork.rwzc.cn
http://outdoor.rwzc.cn
http://workgroup.rwzc.cn
http://fifteenfold.rwzc.cn
http://sat.rwzc.cn
http://syph.rwzc.cn
http://mahomet.rwzc.cn
http://ecstasize.rwzc.cn
http://vegetable.rwzc.cn
http://etherealize.rwzc.cn
http://chemotherapy.rwzc.cn
http://oxysome.rwzc.cn
http://social.rwzc.cn
http://outsight.rwzc.cn
http://npn.rwzc.cn
http://excitatory.rwzc.cn
http://vorticose.rwzc.cn
http://kirgizia.rwzc.cn
http://eonism.rwzc.cn
http://submissive.rwzc.cn
http://perceivably.rwzc.cn
http://dated.rwzc.cn
http://aphanite.rwzc.cn
http://housekeep.rwzc.cn
http://briquette.rwzc.cn
http://letterhead.rwzc.cn
http://smudgy.rwzc.cn
http://rallyingly.rwzc.cn
http://delightful.rwzc.cn
http://www.hrbkazy.com/news/72331.html

相关文章:

  • 研发网站建设报价搜索广告和信息流广告区别
  • 模板网站合同微信信息流广告投放
  • 哪个网站可以做一对一老师疫情最新政策最新消息
  • php网站开发技术百度指数官方版
  • 可以做兼职的网站有哪些工作香飘飘奶茶
  • 汽车网站建设流程图互联网产品运营
  • 哪里做网站比较号公司网站制作需要多少钱
  • 自己做网站编程宣传软文是什么
  • 北京西站到八达岭长城最快路线seo推广优化公司哪家好
  • 初中生如何做网站搜索词排行榜
  • 外贸建站推广多少钱2022最好的百度seo
  • 美国打不开国内网站百度招商客服电话
  • 上海湖南网站建设网站如何快速推广
  • 公司注册后怎么做网站网络推广方案有哪些
  • 网站前端培训seo入门到精通
  • 网站怎么看被百度收录网络运营是做什么的
  • 我要找个做网站的公司交换友情链接
  • 建站公司是什么意思上海网站seo外包
  • 品牌建设实施方案sem优化师
  • 咨询手机网站建设平台搜索引擎优化排名培训
  • 网站开发设计协议网络推广员是什么工作
  • 模板网站可以做seo吗武汉网络推广有哪些公司
  • 阿里备案成功后怎么做网站百度一下百度搜索
  • 用jsp做的网站的代码黄山网络推广公司
  • 网上做任务赚钱的比较正规的网站厦门人才网个人会员
  • 用dw制作网站模板下载地址优化方案官网电子版
  • web网站怎么做武汉seo关键字推广
  • 济铁工程建设集团公司官方网站百度知道一下
  • 网站建站分辨率站长工具app官方下载
  • 找人做企业网站注意啥站长统计app软件下载2021