: 不带任何参数时 curl 将返回指定url中的数据并打印在屏幕上
-o:–output 将指定curl返回保存为out文件,内容从html/jpg到各种MIME类型文件.
-O:–remote-name 按服务器上的名称保存下载的文件
-x/–proxy 在给定的端口上使用HTTP代理
-I header信息
-L 当页面有跳转的时候,输出跳转到的页面
-0/–http1.0 使用HTTP 1.0 (-零)
-w:按照后面的格式写出rt(单位是 秒)
time_namelookup:DNS 解析域名[www.taobao.com]的时间
time_commect:client和server端建立TCP 连接的时间
time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间
speed_download:下周速度 单位 byte/s

<div class="post-text" itemprop="text"> <p>I am attempting to retrieve data from a webpage. Manually changing a dropdown generates content on the page, and that content is stored so that if I refresh the page, the changed data will stay unless I manually change it again. </p> <p>As such, depending on how the dropdown is set, I'll receive different data.</p> <p>I've figured out how to determine what data I want to display by retrieving data fields from the page and changing the URL like so: </p> <p><strong>main.php:</strong></p> <pre><code>public function options($url = null) { // no data fields provided if($url == null) $url = 'http://www.example.com/page/'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $retrievedPage = curl_exec($ch); // retrieve options from drop down menu $regex = '/<div class=\"form\-item form\-type\-select\">(.*?)<\/div>/s'; preg_match($regex, $retrievedPage, $options); $doc = new DOMDocument(); @$doc->loadHTML($options[0]); $ops = $doc->getElementsByTagName('option'); $singleOption = array(); $options = array(); foreach($ops as $op) { $name = $op->nodeValue; $id = $op->getAttribute('value'); $singleOption = array( 'name' => $name, 'id' => $id ); array_push($options, $singleOption); } return $options; } public function updateOptions($id) { $url = 'http://www.example.com/page/?id='.$id; $this->options($url); } </code></pre> <p><strong>index.php:</strong></p> <pre><code><?php $email = 'myemail@example.com'; $password = 'mypassword'; // options() and updateOptions() are in the Account class $user = new Account($email, $password); // options array, initially called to display dropdown options $options = $user->options(); if(isset($_POST['options'])) { $user->updateOptions($_POST['options']); } ?> <form method="POST"> <select name="options" onchange="this.form.submit()"> <?php foreach($options as $key): ?> <?php echo '<option value="'.$key['id'].'">'.$key['name'].'</option>'; ?> <?php endforeach; ?> </select> </form> </code></pre> <p>The dropdown menu successfully looks like this in the HTML: </p> <pre><code> <select> <option value="123">Option 1</option> <option value="456">Option 2</option> </select> </code></pre> <p>The problem is, the changed content won't appear unless I manually refresh my website after the form has been submitted. </p> <p>I placed an echo to check the URL before the <code>curl_exec()</code> and it appears that it is successfully adding the post data fields at the end of the URL but again, the content won't appear unless I manually refresh my website. </p> </div>
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页