<p>Hi,<br>it is my first time use twisted .<br>i want to use the a function pass a url then get the web page<br>the code as :</p>
<div>// <strong>some code call getPage</strong></div>
<div>&nbsp;</div>
<div><em>while id &lt;= 10000000:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getPage(&quot;</em><a href="http://www.mywebsite.com/News.aspx?ID=&quot;+str(id"><em>http://www.mywebsite.com/News.aspx?ID=&quot;+str(id</em></a><em>))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id += 1<br>
</em>//******************************************</div>
<p><strong>the getPage is definition in twisted.web.client</strong></p>
<p><em>def getPage(url, contextFactory=None, *args, **kwargs):<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Download a web page as a string.</em></p>
<p><em>&nbsp;&nbsp;&nbsp; Download a page. Return a deferred, which will callback with a<br>&nbsp;&nbsp;&nbsp; page (as a string) or errback with a description of the error.</em></p>
<p><em>&nbsp;&nbsp;&nbsp; See HTTPClientFactory to see what extra args can be passed.<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; scheme, host, port, path = _parse(url)<br>&nbsp;&nbsp;&nbsp; factory = HTTPClientFactory(url, *args, **kwargs)<br>&nbsp;&nbsp;&nbsp; if scheme == &#39;https&#39;:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from twisted.internet import ssl<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if contextFactory is None:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contextFactory = ssl.ClientContextFactory()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.connectSSL(host, port, factory, contextFactory)<br>&nbsp;&nbsp;&nbsp; else:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.connectTCP(host, port, factory)<br>&nbsp;&nbsp;&nbsp; return factory.deferred</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>--------------------------------------------------------------------------------&nbsp;&nbsp;&nbsp; <br><strong>Question:<br></strong>for the&nbsp; getPage function,if&nbsp; use it to get 10000 page ,it would open/close
<br>connection 10000 times,it is a very large cost。<br>So ,any body can give me some advice?creat a class inherit from HTTPPageGetter(as a protocol class) <br>or HTTPClientFactory?</p>