Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:16:39+00:00 2026-06-03T07:16:39+00:00

I’ve been looking around the internet hoping that this is possible, I basically need

  • 0

I’ve been looking around the internet hoping that this is possible, I basically need to get just the title of a webpage and nothing else.

web crawlers can take a long time performing tasks because they have to load pages before examinining them, this is inefficient for what I am trying to achieve… here’s what I have so far

php code

$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];
}

I want to know whether it would be possible to crawl only part of a page (for example the first 2000 characters of page).

Any help would be appreciated, Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:16:41+00:00Added an answer on June 3, 2026 at 7:16 am

    You could use substr to just grab the first 1000 chars, alternatively, you could use

    $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;
    

    that will only download the first 500 bytes. You can bench that by running something like this extremely ugly rubbish code:

    $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).")\n";
    
    $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).")\n";
    

    If I run that on my site (http://www.focalstrategy.com/), I get:

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

    Against http://en.wikipedia.org/wiki/PHP, I get:

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

    Against Stack Overflow I get:

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

    and against eBay I get:

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

    You can see by testing that SO and eBay don’t support range requests.

    In summary, sites that support this will get a speed up, those that don’t, won’t, you’ll just get the whole code instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.