Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Crawling T he W eb Recursively I n Powershell W ri t e a scrip t or f un ct ion

ID: 3689312 • Letter: C

Question

Crawling The Web Recursively In Powershell

Write a script or function in Powershell, with params $url and $depth. When the user enters the $url and $depth, the script should return all of the hrefs and store them into a hashtable. Then, depending on the $depth,visit each href in the hashtable recursively and store the resulting hrefs into another hashtable (This can be done by making an ArrayList or Array of hashtables). Once it is finished running it should output the total number of links crawled.


Do not worry about crawling relative Hrefs. Crawling Absolute hrefs will be fine. The output should look something like this:

Explanation / Answer

make-hash-table(integer n): HashTable

Create a hash table with n buckets.

get-value(HashTable h, Comparable key): Element

Returns the value of the element for the given key. The key must be some comparable type.

set-value(HashTable h, Comparable key, Element new-value)

Sets the element of the array for the given key to be equal to new-value. The key must be some comparable type.

remove(HashTable h, Comparable key)