Google Ajax Search API Notes


Useful Links


To start...

example01.htm: simple search using google Ajax web api (JavaScript)

google.php: (.txt file) hardcoded, using google Ajax web api, cracked code

example02.php: (.txt file) simple web crawler example to retrieve all urls at a web page; something interesting preg_match_all

** example03.php: (.txt file) simple web search using old google web api, nuSOAP

example04.php: (.txt file) simple example to link to ACCESS database, only works on my local PC as my web host does not support ACCESS, example04.txt

example05.php: (.txt file) simple html parser download from the Internet

example06.php: (.txt file) doGetCachedPage

example07.php: (.txt file) doGetCachedPage

example08.php: (.txt file) get file at url

example09_regular.php: (.txt file) regular expression, preg_match(), it takes four arguments

1. regular expression string
2. source string
3. array variable (stores matches)
4. optional fourth flag (0 if match is found; 1 if match is not found)

Quantifiers for Matching a Recurring Character

Symbol Description Example
* Zero or more instances a*
+ one or more instances a+
? Zero or one instance a?
{n} n instances a{3}
{n,} at least n instances a{3,}
{,n} Up to n instances a{,2}
{n1, n2} At least n1 instances, no more than n2 instances a{1,2}

example10_regular.php: (.txt file)

1. Regular expression attempt to match as many characters as possible
2. Matching range of characters with character class; Negate a character with (^) character

Escape characters that match entire character types

Character Matches
\n new line
\t tab character
\d Any number
\D Anything other than number
\s Any kind of whitespace
\S Anything other than white space
\w Alphanumeric characters (including the underscore character)
\W Anything other than an alphanumeric character or an underscore

example11_regular.php: (.txt file)

Escape characters that act as anchors

Character Matches
\A beginning of string
\b word boundary
\B Not a word boundary
\Z End of string (matches before final newline or at end of string)
\z End of string (matches only at very end of string)

escape chracters to turn off their meaning. e.g. add backslash \ to a "." character to turn off the meaning

Working with subpatterns(), after defining a subpattern, you can treat it as it were itself a character or character class

example12_regular.php: (.txt file)

branches |, with 2 branches => match either the first pattern or the second

Finding Matches Globally with pre_match_all()

The array variable is populated with a multidimensional array, the first element contain every match
First element = every match of the complete regular expression
Additional element = contain matches that correspond to each atom (subpattern in parentheses)

example13_regular.php: (.txt file)

=====================================================================

CS412 Web Data Mgt & XML Homework 1

example04: (.txt file) view content of both tables: Document and Anchor

example14: (.txt file) delete all contents from both tables.

HW1_Query1.php: (.txt file) <select d1.url,d1.title from document d1 such that http://www.umr.edu -> d1;>

Hw1_Query2.php: (.txt file) select d1.url,d1.title from document d1 such that d1 mentions umr;

Hw1_Query3.php: (.txt file) Select d2.base,d2.label from document d1, anchor d2 such that d1 mentions xml where d1.length>100;

Hw1_Query4.php: (.txt file) select x.url from document x such that "http://www.w3c.org" =>|-> x where x.text contains "XML";