Posted on 30-10-2009
Filed Under (Python) by admin
# Bu program Ali Okan YÜKSEL tarafından kodlanmıştır. Öneri, görüş ve sorularınız  için aokany@gmail.com adresine yazabilirsiniz.
import re
import MySQLdb
 
 
 
db=MySQLdb.Connection(host="localhost",user="root",passwd="",db="deucbs")
cursor=db.cursor()
 
cursor = db.cursor()
 
 
 
p1 = re.compile('.*<font face="Times" size="2">|<font size="2" face="Times">.*')
p2 = re.compile('.*<b>(.+)<\/b>.*')
p3 = re.compile('<div.*left:(.+)px;">(.+)</div>.*')
p4 = re.compile('.*<hr>.*')
 
 
fileIN = open( "kamyoncular/izmirkamyoncular_Part1.htm", "r")
 
line = fileIN.readline()
text = ""
yaz = ""
sonraki = 0
linenum = 0
myline =""
 
while line:
    line = fileIN.readline()
    if p1.match(line):
        sonraki = '1'
        yaz = '1'
        print """
"""
        linenum = linenum+1
 
    if sonraki == '1':
        if p2.match(line):
            text += """
    </tr>
    <tr>
    """
            sonraki = '0'
            print """ > """+p2.match(line).group(1)+"""
 
"""
 
 
 
    if yaz == '1':
        if p3.match(line):
            if p4.match(line)==None:
                lineid = p3.match(line).group(1).replace(' ','')
                if(lineid!=""):
                    #print lineid + "==>" + p3.match(line).group(2)
                    #if lineid == "963":
 
                    deger = p3.match(line).group(2)
 
                    if deger[0:3]!="<b>":
#                        strSQL = "INSERT INTO `veri` (`dosya`, `satir`, `sirano`, `kolon`, `veri`, `ex`) VALUES('izmirkamyoncular_Part1.htm', '"+ str(linenum) +"', '0', '"  + lineid+ "', '" + deger + "', '0')"
#                        print strSQL+""""""
#                        cursor.execute (strSQL)
                         print lineid + "==>" + p3.match(line).group(2)
 
 
 
 
 
 
 
 
fileIN.close()
print myline
text = """<table>
<tr>
""" + text + """
</tr></table>"""
 
#log_file = open("converted_1.htm", "w")
#log_file.write(text)
#log_file.close()
(0) Comments    Read More   

Post a Comment
Name:
Email:
Website:
Comments: