php - How to parse multiple html pages into a string?

469

I'm trying to parse the code of multiple html pages into a string, to make like a buffer, and read this string in order to find a specific text that are input, everthing is ok, the only problem, is that I'm not able to load the pages into the string and read after.

$url = 'http://www.test.com/';
$start = 0;
$end = 1120;

$counter = $start;
while ($counter <= $end) {

    /*** a link to search - add the counter value and html to the end of url ***/
    $link = "$url$counter.html";
    /*** get the links ***/
        $data = file_get_contents($link);
        $data = $data.$data;
//      echo $data;

    $counter = $counter + 15;

}

Could someone help me in this case?

Regards

396

Answer

Solution:

$url = 'http://www.test.com/';
$start = 0;
$end = 1120;
$counter = $start;
$data="";
while ($counter <= $end) {
    $link = "$url$counter.html";
    $res = file_get_contents($link);
    If ($res!==false){
       $data .=$res;
    }
    $counter = $counter + 15;

}

People are also looking for solutions to the problem: encryption - 3DES PHP decrypts same result even if a char is added at the end

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.