编程阅读网页 [英] Programmatically reading a web page

查看:137
本文介绍了编程阅读网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C / C ++程序,将动态读取网页,并从中提取信息。举个例子想象一下,如果你想编写一个应用程序跟踪和记录一个eBay拍卖。有没有一种简单的方法来抓取网页?提供此功能的图书馆吗?并且有一种简单的方法来解析页面以获取具体的数据?

I want to write a program in C/C++ that will dynamically read a web page and extract information from it. As an example imagine if you wanted to write an application to follow and log an ebay auction. Is there an easy way to grab the web page? A library which provides this functionality? And is there an easy way to parse the page to get the specific data?

推荐答案

有一个看 cURL库

 #include <stdio.h>
 #include <curl/curl.h>

 int main(void)
 {
   CURL *curl;
   CURLcode res;

   curl = curl_easy_init();
   if(curl) {
     curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
     res = curl_easy_perform(curl);
      /* always cleanup */
    curl_easy_cleanup(curl);
   }
   return 0;
 }

顺便说一句,如果C ++并不严格要求。我鼓励你尝试C#或Java。这是很容易且有一个内置的方法

BTW, if C++ is not strictly required. I encourage you to try C# or Java. It is much easier and there is a built-in way.

这篇关于编程阅读网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆