php regular expression

Asked

Viewed 80 times

0

I’m trying to get a whole source code from a website.

using CURL I used regular expression

    preg_match('/<html>(.*)<\/html>/i', $resultado, $codigo);
    echo $codigo = $codigo[1];  

but it didn’t work... where is the mistake?

  • Which part you want to take?

  • I want to get all the source code. 100% of it

  • 2

    Curl no longer returns this?

  • using the code I posted above, the result is: Notice: Undefined offset: 1

  • The file_get_contents wouldn’t be easier/more practical for you?

  • 1

    verified the content of $resultado ? see what appears with highlight_string($resultado);

  • @Florida he’s wearing CURL

  • florida, giving ECHO in file_get_contents, appears the page, and not its code.

  • 2

    The page may appear pq was rendered by the browser, if vc store it in a variable can manipulate the will.

  • 3

    @rray solved.... thank you very much... using highlight_string($result) appeared the entire page code.... thank you very much

Show 5 more comments

1 answer

3


Can display the source code of a page with highlight_string(), this prevents it from being rendered by the browser, so just something like:

highlight_string($resultado);
  • <CONTENTS> <CONTENTS> <PONTO1> <CONTENTS> <CONTENTS> <PONTO2> <CONTENTS> ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.