English 中文(简体)
仅限页标题
原标题:Crawling for only the title of a page

我一直在研究因特网,希望这样做是可能的,我基本上只需要一个网页的名称,而别无其他名称。

网上拖网渔船可能要花很长的时间来执行任务,因为他们必须装上网页,才能对他们进行考试,这对我试图实现的目标来说,效率不高。

<><><><>>>

$url =  http://www.ebay.com/itm/300702997750#ht_500wt_1156 ;
$str = file_get_contents($url);
$title =   ; 

if(strlen($str)>0){
   preg_match("/<title>(.*)</title>/",$str,$titleArr);
   $title = $titleArr[1];
}

我想知道,是否只能将某一页的一部分(例如2000年首页的特征)rawl倒。

希望得到任何帮助, 感谢。

最佳回答

你们可以使用亚str,只 gr头1 000个果园,否则你可以使用。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,  http://www.example.com/ );
curl_setopt($ch, CURLOPT_RANGE,  0-500 );
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;

这只能下载头500tes。 你们可以nch笑,像这种极其荒谬的法典:

$url =  http://www.example.com/ ;
$range = array();
$repeats = 10;

function average($a){
  return array_sum($a)/count($a) ;
}

for ($i=0;$i<$repeats;$i++) {
    $time_start = microtime(true);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RANGE,  0-500 );
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);

    $time_end = microtime(true);
    $time = $time_end - $time_start;
    curl_close($ch);
    $range[] = $time;
}
echo "With range: average = ".round(average($range),2)." seconds (Min: ".round(min($range),2).", Max: ".round(max($range),2).")
";

$range = array();

for ($i=0;$i<$repeats;$i++) {
    $time_start = microtime(true);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);

    $time_end = microtime(true);
    $time = $time_end - $time_start;
    curl_close($ch);
    $range[] = $time;
}
echo "Without range: average = ".round(average($range),2)." seconds (Min: ".round(min($range),2).", Max: ".round(max($range),2).")
";

如果我在网站(http://www.focalstrategy.com/)上,我会:

With range: average = 0.38 seconds (Min: 0.35, Max: 0.41)
Without range: average = 0.56 seconds (Min: 0.53, Max: 0.7)

反对http://en.wikipedia.org/wiki/PHP 我收到了:

With range: average = 0.11 seconds (Min: 0.05, Max: 0.5)
Without range: average = 0.48 seconds (Min: 0.34, Max: 0.78)

反对Stack Overflow 我收到了:

With range: average = 1.31 seconds (Min: 1.1, Max: 1.46)
Without range: average = 1.37 seconds (Min: 1.18, Max: 1.7)

http://www.ebay.com/“rel=“nofollow noreferer”>。 我收到了:

With range: average = 1.75 seconds (Min: 1.56, Max: 1.99)
Without range: average = 1.74 seconds (Min: 1.51, Max: 2.14)

你们可以通过测试发现,SO和EBay没有支持范围要求。

简言之,支持这项工作的场所将加快,那些没有、赢得的场所,你们只是拿到整个法典。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签