Autofill a form of another website and send it

前端 未结 2 1129
余生分开走
余生分开走 2020-12-20 04:32

I searched the web and found nothing.

On the website, there is a Input box for a E-Mail address. I would like to fill this field with an e-mail address and the send

2条回答
  •  无人及你
    2020-12-20 04:45

    You will need to look at the form action attribute. This should point you to the script the form is posted to. When you have that information you can send a POST request to that url using curl or when in php,

    $postdata = http_build_query(
        array(
            'email' => 'youremailaddress'
        )
    ); 
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
        )
    );
    
    $context  = stream_context_create($opts);
    
    $result = file_get_contents('http://example.com/submit.php', false, $context);
    

提交回复
热议问题