Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a webpage in php

I was wondering how I could download a webpage in php for parsing?

like image 585
Hugo Avatar asked Jun 17 '10 13:06

Hugo


People also ask

How can I download PHP page?

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.

Can I download PHP file from website?

As the PHP is server-side language, you can not download any . php file from any website like the Javascript file.

How can I download zip file from URL in PHP?

Try this code :". zip"; $file = fopen($destination, "w+"); fputs($file, $data); fclose($file);


1 Answers

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.

like image 129
Gordon Avatar answered Oct 20 '22 20:10

Gordon