Appendix A. Script Listings

Chapter 2

Please note that some of these scripts are used to query search engines. Take extra caution before using these scripts in particular.

spiderviewer.php

<html> <head> <title>Search Engine Web Page Viewer</title> </head> <body> <form name=mainform action="" method="get"> <table border="0" width="100%" align=center> <tr> <td>Enter URL: <br> <input type="text" name="url" size="20"></td> </tr> <tr> <td> <input type="submit" value="Click to See Search Engine View" name="submit"> </td> </tr> </table> </form> <hr> <?php $myurl = $_GET['url']; if (isset($myurl)) { print spiderViewer($myurl); } ?> </body> </html> <?php function spiderViewer($url) { $finalHTML=''; if($url) { $originalHTML=get_content($url); if($originalHTML) { $finalHTML.='<table border="0" align="center" width="75%">'; $finalHTML.='<tr><td align="center" valign="top">'; $finalHTML.='<b>Search Engine View for URL:' . $url . '</b></tr>'; $finalHTML.='<tr><td align="left" valign="top">'; $originalHTML=preg_replace('/<script.*?>.*?<\/script.*?>/sim' ,'', $originalHTML); $originalHTML=preg_replace('/<object.*?>.*?<\/object.*?>/sim' ,'', $originalHTML); $originalHTML=preg_replace('/<applet.*?>.*?<\/applet.*?>/sim' ,'', $originalHTML); $originalHTML=preg_replace('/<style.*?>.*?<\/style.*?>/sim' ,'', $originalHTML); $originalHTML=preg_replace('/<.*?>/sim','',$originalHTML); $originalHTML=preg_replace('/&[#]{0,1}.[^ ]*;/sim',' ' ,$originalHTML); $stopWordsArray=explode("<br />", file_get_contents('stopwords.txt')); ...

Get SEO Warrior now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.