【问题标题】:downloading words with libcurl用 libcurl 下载单词
【发布时间】:2016-01-12 00:20:17
【问题描述】:

我正在尝试下载网站中的文字(包括标题)。我正在使用 libcurl 的选项:

  curl_easy_setopt(myHandle, CURLOPT_HEADER, 0);

删除不必要的数据。但是,我得到了样式数据:

example.com:

 Example Domain     body { background-color: #f0f0f2; margin: 0; padding: 0; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;  } div { width: 600px; margin: 5em auto; padding: 50px; background-color: #fff; border-radius: 1em; } a:link, a:visited { color: #38488f; text-decoration: none; } @media (max-width: 700px) { body { background-color: #fff; } div { width: auto; margin: 0 auto; border-radius: 0; padding: 1em; } }   Example Domain This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission. More information...http://www.iana.org/domains/example

是否有其他选项可以删除以下行:

body { background-color: #f0f0f2; margin: 0; padding: 0; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;  } 

还是我必须手动解析字符?

【问题讨论】:

  • 你为什么用c来做这个,用高级语言不是更容易吗?
  • 我觉得使用 C 很舒服

标签: c libcurl


【解决方案1】:

libcurl 不会区分不同类型的内容。您将需要使用其他一些库来解析并删除它。

【讨论】:

    【解决方案2】:

    我只是选择使用以下方法从页面中完全删除标题:

    htmlCode = strstr(htmlCode, "</head>");
    

    现在应该这样做

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-13
      • 2011-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多