diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2013-04-20 13:30:05 +0200 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2013-04-20 13:30:05 +0200 |
commit | 2f4a252454906325e49cfa4fe2b39e3e00f0621c (patch) | |
tree | 7dfbd336488a80ec1ce1093abbdf5b76915a50e2 /toys/brhute-py/twisted_http.py | |
parent | brhute: move to dedicated dir (diff) | |
download | laurent-tools-2f4a252454906325e49cfa4fe2b39e3e00f0621c.tar.xz laurent-tools-2f4a252454906325e49cfa4fe2b39e3e00f0621c.zip |
brhute: move to brhute-py
Diffstat (limited to 'toys/brhute-py/twisted_http.py')
-rw-r--r-- | toys/brhute-py/twisted_http.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/toys/brhute-py/twisted_http.py b/toys/brhute-py/twisted_http.py new file mode 100644 index 0000000..805c78a --- /dev/null +++ b/toys/brhute-py/twisted_http.py @@ -0,0 +1,26 @@ +from twisted.web import client +from twisted.internet import reactor, defer + +urls = [ + 'http://www.python.org', + 'http://stackoverflow.com', + 'http://www.twistedmatrix.com', + 'http://www.google.com', + 'http://www.google.com/toto', + 'http://www.google.com/titi', + 'http://www.google.com/tata', + 'http://launchpad.net', + 'http://github.com', + 'http://bitbucket.org', +] + +def finish(results): + for result in results: + print 'GOT PAGE', len(result), 'bytes' + reactor.stop() + +factory = client.HTTPClientFactory() +waiting = [client.getPage(url, factory) for url in urls] +defer.gatherResults(waiting).addCallback(finish) + +reactor.run() |