Skip to content

Instantly share code, notes, and snippets.

@omundy
Created May 16, 2011 11:20
Show Gist options
  • Save omundy/974261 to your computer and use it in GitHub Desktop.
Save omundy/974261 to your computer and use it in GitHub Desktop.
Basic scraping demo with "find-replace" parsing
<?php
/* Basic scraping demo with "find-replace" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
$url = "http://www.bbc.co.uk/news/"; // 0. url to start with
$contents = file_get_contents($url); // 1. get contents of page in a string
// 2. search and replace contents
$contents = str_replace( // str_replace(search, replace, string)
"News",
"<b style='background:yellow; color:#000; padding:2px'>LIES</b>",
$contents);
print $contents; // 3. print result
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment