|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'd like some help with writing a script that grabs part of another HTML page.
For example : I want to grab the content of a HTML page that contains the following strings : <!-- begin --> and <!-- end --> Then I want to get all the content (including these two tags) that is in between the two tags. Could someone help me? Thanks, Iwan |
|
#2
|
|||
|
|||
|
<?
$server = "www.whatever.com"; $file = "/path/to/file.html"; $fp = fsockopen($server, 80, &$errno, &$errstr); if ($fp) { fputs($fp,"GET $file HTTP/1.0nHost: $servernn"); $getit = false; while ($line = fgets($fp, 4096)) { if (eregi("<!-- begin -->", $line)) { $getit = true; } elseif (eregi("<!-- end -->", $line)) { $getit = false; } if ($getit == true) { $lines[] = $line; } } fclose($fp); } ?> A bit of a kludge, but it works (I hope :-) |
|
#3
|
|||
|
|||
|
Thanks a lot!
It works perfectly, exactly what I needed! Iwan |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Getting part of another HTML page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|