Problem here is both module name and variable name is same 're'.<br>It should be like as follows, <br><font face="Courier, Monospaced"><b>rec</b>=cur.fetchall() <br>
if len(rec)!=0: <br>
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"><<a href="mailto:ylj798@gmail.com">ylj798@gmail.com</a>></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="localhost",user="root",passwd="ylj",db="net", charset="utf8") <br>
cur = conn.cursor() <br>
sql='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' <br>
cur.execute(sql) <br>
re=cur.fetchall() <br>
if len(re)!=0: <br>
for i in re: <br>
down_re="%s"%(i[1]) <br>
source_url="%s"%(i[4]) <br>
data= urllib2.urlopen(source_url).read() <br>
res=re.compile(down, re_DOTALL).findall(data) <br>
print str <br>
---------------------------------------------------------------------------<br>
when it's run,the eric give error <br>
------------- <br>
The debugged program raised the exception unhandled AttributeError <br>
"'tuple' object has no attribute 'compile'" <br>
File: /var/www/py/down.py, Line: 27 <br>
------------ <br>
the line:27 -------> 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>