Skip to content

Instantly share code, notes, and snippets.

@bovine
Created October 23, 2015 17:55
Show Gist options
  • Save bovine/fccfb2b8c546d5f64581 to your computer and use it in GitHub Desktop.
Save bovine/fccfb2b8c546d5f64581 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/tclsh8.6
package require http
package require autoproxy
package require tls
proc init1 {} {
set http_proxy_host "proxy"
set http_proxy_port 8118
::autoproxy::init
::http::register https 443 [list ::autoproxy::tls_socket -ssl2 0 -ssl3 0 -tls1 1]
::autoproxy::configure -proxy_host $http_proxy_host -proxy_port $http_proxy_port
}
proc init2 {} {
::http::register https 443 ::tls::socket
}
proc scrape {} {
set pageUrl "https://www.google.com/"
set fp [::http::geturl $pageUrl -timeout 10000]
set status [::http::status $fp]
set ncode [::http::ncode $fp]
set html [::http::data $fp]
array set headers [::http::meta $fp]
::http::cleanup $fp
}
init1
for {set i 0} {$i < 1000} {incr i} {
puts "request $i"
scrape
puts [exec "/bin/ps" "auxw" "-p" [pid]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment