aboutsummaryrefslogtreecommitdiffstats
path: root/toys/brhute-py/twisted_http.py
blob: 805c78ae1ec013230a792727fb6e4e0da54a66b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()