Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何让卷发在刮之前等待几秒钟?_Php_Curl_Web Scraping - Fatal编程技术网

Php 如何让卷发在刮之前等待几秒钟?

Php 如何让卷发在刮之前等待几秒钟?,php,curl,web-scraping,Php,Curl,Web Scraping,所以我试图从一个网站上搜集一些数据。 有一张名单必须删掉。 结果是,如果有15个名字需要删掉。其中只有5个名字被删掉了 当我检查原始站点时,他们也以类似的方式加载数据。第一次加载站点时。仅显示五个名称。重新加载时,将显示10个名称,重试时将显示所有15个数据 有谁能告诉我如何让卷曲在抓取原始数据之前等待几秒钟。这样所有的内容都可以被删除 以下是带有curl集选项的部分代码片段: $post = curl_init(); curl_setopt($post, CURLOPT_URL

所以我试图从一个网站上搜集一些数据。 有一张名单必须删掉。 结果是,如果有15个名字需要删掉。其中只有5个名字被删掉了

当我检查原始站点时,他们也以类似的方式加载数据。第一次加载站点时。仅显示五个名称。重新加载时,将显示10个名称,重试时将显示所有15个数据

有谁能告诉我如何让卷曲在抓取原始数据之前等待几秒钟。这样所有的内容都可以被删除

以下是带有curl集选项的部分代码片段:

    $post = curl_init();
    curl_setopt($post, CURLOPT_URL, $url);
    curl_setopt($post, CURLOPT_AUTOREFERER, true);
    curl_setopt($post, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt($post, CURLOPT_TIMEOUT, 2 );
    $img_contents = curl_exec($post);
    curl_close($post);

    $html= str_get_html($img_contents);
foreach($html->find('div[id=xxxx]') as $stay2)
{

$stay4=$stay2->find('span[class=xxx]');

    foreach($stay4 as $stay6)
    {   
        echo $abc[]= strip_tags($stay6) ."<br/>";
    }
 }
$post=curl_init();
curl_setopt($post,CURLOPT_URL,$URL);
curl_setopt($post,CURLOPT_AUTOREFERER,true);
curl_setopt($post,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($post,CURLOPT_RETURNTRANSFER,1);
curl_setopt($post,CURLOPT_超时,2);
$img\u contents=curl\u exec($post);
旋涡关闭(员额);
$html=str_get_html($img_contents);
foreach($html->find('div[id=xxxx]”)作为$stay2)
{
$stay4=$stay2->find('span[class=xxx]');
foreach($stay4作为$stay6)
{   
echo$abc[]=strip_标签($stay6)。“
”; } }
添加睡眠($s)请参见

感谢ans sem,但它不起作用:嗯,我想应该有卷曲的功能。啊,你要做的就是让卷发在一个执行器的中间等待。据我所知,这是不可能的,你可以做的是保留一个带有名字的列表,然后擦擦几次,然后把它添加到列表中。如果你说他们也等待几秒钟,那就意味着他们做了一个异步获取。(可能是延迟的ajax调用)您可以尝试找出这些调用(firebug是一种方法,我相信还有其他方法),然后使用curl分别调用这些调用