From c7f6843ea2dfe31dbd4e3edfd09e5ad230e2af24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 3 Apr 2023 13:17:40 -0400 Subject: Add circle to pi Display, center shapes correctly --- play/Example_Domain.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ play/wget.tcl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 play/Example_Domain.html create mode 100644 play/wget.tcl (limited to 'play') diff --git a/play/Example_Domain.html b/play/Example_Domain.html new file mode 100644 index 00000000..5a9b52fc --- /dev/null +++ b/play/Example_Domain.html @@ -0,0 +1,46 @@ + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + diff --git a/play/wget.tcl b/play/wget.tcl new file mode 100644 index 00000000..65e03076 --- /dev/null +++ b/play/wget.tcl @@ -0,0 +1,35 @@ +if {0} { + example syntax: Wish $this downloads "URL" + + When someone wishes for a page to be downloaded we check to see if there's + $title.html in the current directory. If there is, we don't download it. + + If there isn't, we download the page and save it as $title.html +} + + +# proc called findTitle that searches a string of HTML for the title using regexp and returns the text of the title +proc findTitle {webpage} { + set title [regexp -inline -all -line -lineanchor {(.*)} $webpage] + return [lindex $title 1] +} + +# proc called getWebpage that takes a URL, uses exec & wget to print out the content as a string +proc getWebpage {URL} { + set webpage [exec wget -q -O - $URL] + return $webpage +} + +# proc called download that takes a URL, uses getWebpage to download the content to a file +proc download {URL} { + set webpage [getWebpage $URL] + set title [string map {" " "_"} [findTitle $webpage]] + puts "title: $title" + puts "writing to file $title.html" + set file [open $title.html w] + puts $file $webpage + close $file +} + +# this works! downloads example.com to Example_Domain.html +download example.com \ No newline at end of file -- cgit v1.2.3