How to read http files with php?
Moderator: General Moderators
How to read http files with php?
I would like an script capable of reading files using http.
I have tried "readfile" and "fopen" and it didn't wor for me (those only read "files", not the http parsed code).
(I think is not a problem of "allow_url_open" permissions, cause I only need to read the html parsed info).
What I really need is some script that can read the html parsed code from a php (or mere html) file or URL in the net.
Then I could filter it, and extract -filter- some information from the "readed" html.
---------
All suggestions are really welcome.
To more detailed sugestions, I will share my project (about PostNuke atomated update)
-----
Thanks
jeanloui
http://imagicweb.com
I have tried "readfile" and "fopen" and it didn't wor for me (those only read "files", not the http parsed code).
(I think is not a problem of "allow_url_open" permissions, cause I only need to read the html parsed info).
What I really need is some script that can read the html parsed code from a php (or mere html) file or URL in the net.
Then I could filter it, and extract -filter- some information from the "readed" html.
---------
All suggestions are really welcome.
To more detailed sugestions, I will share my project (about PostNuke atomated update)
-----
Thanks
jeanloui
http://imagicweb.com
I'll try curl, but it seems to need some special php install (and I need reading also html "http" parsed code):feyd wrote:[php_man]curl[/php_man]
Code: Select all
"Once you've compiled PHP with CURL support, you can begin using the CURL functions (---)"Thanks.
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
Totally off topic but has any notice the comments are gone from PHP manual? Those comments had many helpful examples.jeanloui wrote:Also an small example can help a lot.
What's left? Sockets?
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
err..
index.php
file_test.php
would echo 3 = a + b, not the php code, so what's the issue?
index.php
Code: Select all
<?php
$a = 1;
$b = 2;
echo $a+b . " = a + b!";
?>Code: Select all
<?php
$contents = file_get_contents("http://mysite.com/index.php");
echo $contents;
?>I'll try to explain best
err..LiLpunkSkateR wrote:err..
This begins to work, but...
It's suposed that an html or php file called from http produces something like:
Code: Select all
<html>
<body>
hello
</body>
</html>I need an script that echoes:
Code: Select all
<html>
<body>
hello
</body>
</html>There I could (I will) filter all the text (avoiding or including TAGS) and extract some concrete information of the parsed html text.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
It does print that.. viewing it in the browser however shows you the result (the HTML parsed). If you view the source, it's exactly what you want.
Anyways, I kinda see what you're getting at.. but.. you're gonna need more than this to pull the info (more string functions or a regex pattern):
Anyways, I kinda see what you're getting at.. but.. you're gonna need more than this to pull the info (more string functions or a regex pattern):
Code: Select all
<?php
$contents = file_get_contents("http://mysite.com/index.php");
$contents = str_replace("<","<",$contents);
$contents = str_replace(">","&rt;",$contents);
echo $contents;
?>LiLpunkSkateR wrote:It does print that.. viewing it in the browser however shows you the result (the HTML parsed). If you view the source, it's exactly what you want.
Yes, I know but I think this is exactly what I was needing to begin filtering!... you're gonna need more than this to pull the info (more string functions or a regex pattern)
Thank you very much!
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA