【发布时间】:2010-09-30 03:08:35
【问题描述】:
我正在使用 cURL 来抓取网页,但我似乎只能抓取顶级 URL。例如,如果我想卷曲 URL“http://www.businessweek.com/news/2010-09-29/flaherty-says-canada-july-gdp-report-tomorrow-may-be- negative.html" 然后它什么也不返回(好像它是一个空白页)。
这是我的 C 代码:
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
//THIS WORKS
//curl_easy_setopt(curl, CURLOPT_URL, "news.google.com");
//THIS DOESN'T WORK
curl_easy_setopt(curl, CURLOPT_URL, "http://www.businessweek.com/news/2010-09-29/flaherty-says-canada-july-gdp-report-tomorrow-may-be-negative.html");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
如果我能就这个问题获得一些意见,那就太好了。
【问题讨论】: