Skip to content

Instantly share code, notes, and snippets.

@kjam
kjam / geturl.tcl
Created January 20, 2017 17:25
TCL & Perl Web scraper from The Practice of Programming by Brian W. Kernighan and Rob Pike
# geturl.tcl: retrieve document from URL
# input has form [http://]abc.def.com[/whatever...]
regsub "http://" $argv "" argv ;# remove http:// if present
regsub "/" $argv " " argv ;# replace leading / with blank
set so [socket [lindex $argv 0] 80] ;# make network connection
set q "/[lindex $argv 1]"
puts $so "GET $q HTTP/1.0\n\n" ;# send request
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am kjam on github.
  • I am kjam (https://keybase.io/kjam) on keybase.
  • I have a public key whose fingerprint is E197 50BD D484 DFF5 671D 7874 1F54 1EC6 1DE7 119B

To claim this, I am signing this object:

import json
import agate
from print_int_table_issue import * #note: to not throw the other error you'll need to comment out the last line
def get_country(country_row):
return country_dict.get(country_row['Country / Territory'].lower())
country_dict = {}
country_json = json.loads(open('earth-cleaned.json', 'rb').read())
import agate
import xlrd
from xlrd.sheet import ctype_text
text_type = agate.Text()
number_type = agate.Number()
boolean_type = agate.Boolean()
date_type = agate.Date()
def remove_bad_chars(val):