I was wondering how I could download a webpage in php for parsing?
Since you will likely want to parse the page with DOM, you can load the page directly with: $dom = new DOMDocument; $dom->load('http://www.example.com'); when your PHP has allow_url_fopen enabled. But basically, any function that supports HTTP stream wrappers can be used to download a page.
As the PHP is server-side language, you can not download any . php file from any website like the Javascript file.
Try this code :". zip"; $file = fopen($destination, "w+"); fputs($file, $data); fclose($file);
Since you will likely want to parse the page with DOM, you can load the page directly with:
$dom = new DOMDocument;
$dom->load('http://www.example.com');
when your PHP has allow_url_fopen enabled.
But basically, any function that supports HTTP stream wrappers can be used to download a page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With