Forum Moderators: coopster

Message Too Old, No Replies

Capture HTML

         

andrewsmd

2:35 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know if this is possible, but I have a PHP page that re-directs to another page. Now the link it redirects to is dynamic but is there anyway I can capture the source HTML of the link with PHP. What I mean is say I have this
header("Location: somepage.html"); Before I re-direct is there anyway I could get the HTML source of somepage.html. It doesn't have to be with PHP but if I can do it with that I would like to. I'm trying to search the HTML for content before I redirect the user that is why I need to do this. Thanks,

cameraman

3:01 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out the cURL [us.php.net] functions. It looks pretty daunting at first but you can get the hang of it pretty quickly. Look at curl_init [us.php.net] and curl_setopt [us.php.net]. You want to use CURLOPT_RETURNTRANSFER so that the page gets returned into a variable instead of being sent straight to the browser.

andrewsmd

4:43 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I will check it out and let you know. P.S. this is the best web forum ever. If some admin of this site sees this, TELL YOUR BOSS!

andrewsmd

5:38 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I tried these out and it turns out I don't have curl enabled. I found some things online about copying dll to windows folders and I did that but I don't know what else to do. Do you have any suggestions on how to install.

cameraman

5:42 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make sure the extension is enabled in your php.ini file.

andrewsmd

6:04 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I went into the php.ini I could not find that extension. That is why I was wondering how to install it.

cameraman

6:12 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Last time I installed php it put headers in like that first line, if yours doesn't have those on other extensions you just need the second line.
[PHP_CURL]
extension=php_curl.dll

enigma1

6:12 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have database access then you could store the html output of each page to the database and do the search there. Unless of course you have personalized content in which case you should deploy a database search by entity (eg: product, text article etc).

andrewsmd

7:23 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not worried about storing the output, I just can't get the actual HTML right now.

andrewsmd

7:24 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I added that to my php.ini file but it didn't work. Are there some ms dos commands I need to run like when I installed PEAR.

cameraman

8:19 pm on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, no msdos commands to run. You might try putting php_curl.dll in your php extensions directory instead of your system directory (or whichever windows folder you put it into that you indicated a couple posts ago).

Anyango

8:01 am on Nov 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why cant we simply use file_get_contents, Why does it have to be so difficult for someone to just grab HTML from some page ?

<?
$yourHTML=file_get_contents("http://www.example.com/somepage.html");
?>

barns101

3:35 pm on Nov 22, 2008 (gmt 0)

10+ Year Member



I added that to my php.ini file but it didn't work.

Did you restart PHP after modifying php.ini?

andrewsmd

1:17 pm on Nov 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't use file_get_contents because everytime I try that it doesn't work.

andrewsmd

1:46 pm on Nov 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got it working. It was the extension problem. I just put the dll in my windows dll folder and the PHP extension and it worked fine. Thanks for everyone's help.