Date: 2010mar27
Language: php
Q. How can I do a wget in php?
A. There are several ways. You can shell out to wget.
But for normal use here are some ways.
# Just use copy!
function fetchUrl1($url, $file) {
return copy($url, $file);
}
# I prefer this one since you can tell if getting the URL failed
# there was a permission (etc) problem locally.
function fetchUrl2($url, $filename) {
if (($s = file_get_contents($url)) === false) return false;
return file_put_contents($filename, $s);
}
As I said, there are other ways.
| What this info useful to you? You can donate to say thanks |
Add a comment
Sign in to add a comment