【问题标题】:PHP: programatically submit form and get contents of resulting page?PHP:以编程方式提交表单并获取结果页面的内容?
【发布时间】:2010-12-03 11:34:07
【问题描述】:

我将如何使用 PHP(我假设使用 curl?)以编程方式提交表单并获取结果页面的文件标记?

【问题讨论】:

  • 感谢您的冷嘲热讽。

标签: php curl


【解决方案1】:

有关此内容的相关详细信息,请参见此处:

http://www.html-form-guide.com/php-form/php-form-submit.html

例如:

<?php
   $url = 'http://localhost/curl/1.php';
   $params = "keyword=123&zxczxc=333"; //you must know what you want to post
   $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_POST,1);
   curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
   curl_setopt($ch, CURLOPT_URL,$url);
   curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

   $result=curl_exec ($ch);
   curl_close ($ch);

   echo "Results: <br>".$result;
?>

1.php内容:

<?
print_r($_POST);
?>

关于 SO 的相关问题:

https://stackoverflow.com/search?q=php+form+curl

Posting a textarea form with cURL

Using PHP & curl to post an html form that includes a file

php cURL , fill a remote form

其他文章:

http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html

http://davidwalsh.name/execute-http-post-php-curl

http://curl.haxx.se/mail/curlphp-2004-04/0013.html

http://phpsense.com/php/submitting-forms-using-php-curl.html

http://www.maheshchari.com/submit-a-form-to-remote-server-with-php-curl/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-22
    • 1970-01-01
    • 2015-03-09
    • 2016-09-11
    • 2018-06-13
    • 1970-01-01
    相关资源
    最近更新 更多