开发者

How can I scrape a page and extract all linked resources' urls in php?

开发者 https://www.devze.com 2023-03-15 20:33 出处:网络
I\'m actually wondering if there\'s some library or code available to do this with. Essentially, all I need to do is scrape a page with PHP, including it\'s CSS files, JavaScript, and images, and repl

I'm actually wondering if there's some library or code available to do this with. Essentially, all I need to do is scrape a page with PHP, including it's CSS files, JavaScript, and images, and replace those URL'开发者_Python百科s in the code with the URL of a local copy.

Any help or links to info on the subject would be really appreciated. Thank you.


SimpleHTMLDom - see the examples on the homepage for an easy method to extract and loop through links


$new_page_content = str_replace( $old_url, $new_url, $page_content );

PHP Manual: str_replace()

0

精彩评论

暂无评论...
验证码 换一张
取 消