Problem here is both module name and variable name is same &#39;re&#39;.<br>It should be like as follows, <br><font face="Courier, Monospaced"><b>rec</b>=cur.fetchall() <br>
if len(rec)!=0: <br>
&nbsp; &nbsp; &nbsp;for i in rec: </font><br><br><br><div class="gmail_quote">On Wed, Nov 12, 2008 at 4:02 PM, yao <span dir="ltr">&lt;<a href="mailto:ylj798@gmail.com">ylj798@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div bgcolor="#ffffff" text="#000000">
<font face="Courier, Monospaced">my code <br>
-------------------------------------------------------------------------------------------
<br>
# -*- coding: utf8 -*- <br>
#!/usr/bin/python <br>
</font>
<p><font face="Courier, Monospaced">import urllib <br>
import urllib2 <br>
import re <br>
import MySQLdb <br>
</font></p>
<font face="Courier, Monospaced">conn=MySQLdb.connect
<br>
(host=&quot;localhost&quot;,user=&quot;root&quot;,passwd=&quot;ylj&quot;,db=&quot;net&quot;, charset=&quot;utf8&quot;) <br>
cur = conn.cursor() <br>
sql=&#39;select <br>
net_site.downline_re,net_site.down_re,<a href="http://net_cha.id" target="_blank">net_cha.id</a>,net_cha.urlid,net_cha.source_url
<br>
from net_site,net_cha where <a href="http://net_site.id" target="_blank">net_site.id</a>=net_cha.urlid&#39; <br>
cur.execute(sql) <br>
re=cur.fetchall() <br>
if len(re)!=0: <br>
&nbsp; &nbsp; &nbsp;for i in re: <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;down_re=&quot;%s&quot;%(i[1]) <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source_url=&quot;%s&quot;%(i[4]) <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data= urllib2.urlopen(source_url).read() <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res=re.compile(down, re_DOTALL).findall(data) <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print str <br>
---------------------------------------------------------------------------<br>
when it&#39;s run,the eric give error <br>
------------- <br>
The debugged program raised the exception unhandled AttributeError <br>
&quot;&#39;tuple&#39; object has no attribute &#39;compile&#39;&quot; <br>
File: /var/www/py/down.py, Line: 27 <br>
------------ <br>
the line:27 -------&gt; res=re.compile(down, re_DOTALL).findall(data) </font>
</div>

<br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br>