Hi,<br><br>I am having problem compiling twisted sample codes. It gives me "Import Error" errors (i.e. ImportError: No module named web.client). I really appreciate any suggestions. Thank you.<br><br>Below is the sample codes that I tried from the tutorial<br>
<br><b><i>from twisted.web.client import getPage<br>from twisted.internet import reactor<br><br>def printContents (contents):<br> '''<br> This is the 'callback' function, added to the Deferred and called by<br>
it when the promised data is available<br> '''<br> <br> print "The Deferred has called printContents with the following contents:"<br> print contents<br> <br> # Stop the Twisted event handling system -- this is usually handled<br>
# in higher level ways<br> <br> reactor.stop()<br> <br># call getPage, which returns immediately with a Deferred, promising to<br># pass the page contents onto our callbacks when the contents are available<br>
deferred = getPage ("<a href="http://twistedmatrix.com/">http://twistedmatrix.com/</a>")<br><br># add a callback to the deferred -- request that it run printContents when<br># the page content has been downloaded<br>
deferred.addCallback (printContents)<br><br>reactor.run()</i></b><br>