Hi,<br><br>I am having problem compiling twisted sample codes. It gives me &quot;Import Error&quot; 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>&nbsp;&nbsp;&nbsp; &#39;&#39;&#39;<br>&nbsp;&nbsp;&nbsp; This is the &#39;callback&#39; function, added to the Deferred and called by<br>
&nbsp;&nbsp;&nbsp; it when the promised data is available<br>&nbsp;&nbsp;&nbsp; &#39;&#39;&#39;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; print &quot;The Deferred has called printContents with the following contents:&quot;<br>&nbsp;&nbsp;&nbsp; print contents<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; # Stop the Twisted event handling system -- this is usually handled<br>
&nbsp;&nbsp;&nbsp; # in higher level ways<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; reactor.stop()<br>&nbsp;&nbsp;&nbsp; <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 (&quot;<a href="http://twistedmatrix.com/">http://twistedmatrix.com/</a>&quot;)<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>