【问题标题】:cUrl alternatives to get POST answer on a webpage在网页上获取 POST 答案的 cUrl 替代方法
【发布时间】:2012-07-13 04:48:00
【问题描述】:

我想获取特定表单提交的结果网页。此表单使用 POST,因此我目前的目标是能够将 POST 数据发送到 url,并在变量中获取结果的 HTML 内容。

我的问题是我不能使用 cUrl(未启用),这就是为什么我要求您知道是否有其他解决方案。

提前致谢

【问题讨论】:

  • 我会试着找到我的方式,即使它对我来说是全新的^^谢谢

标签: php javascript html curl


【解决方案1】:

尝试 file_get_contents() 和流

$opts = array(  'http'=>array('method'=>"POST", 'content' => http_build_query(array('status' => $message)),));

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);

【讨论】:

    【解决方案2】:

    看到这个,使用 fsockopen: http://www.jonasjohn.de/snippets/php/post-request.htm

    Fsockopen 在 php 标准库中,所以所有 php 版本 4 都有它:)

    【讨论】:

    • 我的主机 (free.fr) 显然在 3 年前在 url 上也禁用了 fsockopen 和 fopen。无论如何我会看看你的链接,谢谢
    猜你喜欢
    • 2011-02-09
    • 2021-04-21
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-26
    • 1970-01-01
    相关资源
    最近更新 更多