This snippet of PHP code demonstrates web scraping. It reads a sample page from Amazon.com, compares the HTML text against certain class name and outputs that matched text in an RSS feed. <?php $now = date("D, d M Y H:i:s T"); $ASIN = $url = $img = $title = $bio = $name = ""; $head = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $head .= '<rss version="2.0">'; $head .= '<channel>'; $head .= '<title>Amazon </title>'; $head .= '<link>http://www.amazon.com</link>'; $head .= '<description>Amazon RSS Feed</description>'; $url = "http://www.amazon.com/Best-Sellers-Kindle-Store/zgbs/digital-text/"; $text = file_get_html($url); foreach ($text->find("div.zg_item_compact") as $class) { foreach ($class->find('strong.price') as $price) { if ($price->plaintext == "Free...
Comments
Post a Comment