1

I want to get the plain text of web pages, where the urls are stored and then do an update in the same table adding the text. For some reason, after opening around 800 links the program ends. Here is part of the code:

db=_mysql.connect("localhost",user="",passwd="",db="noticias")
db.query("""select id,url from news where id>17821""")
results = db.store_result()
numrows = results.num_rows()

for i in range(0,numrows):
 row = results.fetch_row()
 link = row[0][1] # URL to open
  while True:
   try:
    SourceCode = urlopen(link) 
    break
    except:

    .........
SourceCode.read()
    SourceCode.close()
.........

 title = str(title)
 plaintext = str(plaintext)
 query = "UPDATE news SET title = '"+title+"',plaintext ='"+plaintext+"' WHERE id ="+row[0][0]
 try:
  db.query(query)
  break
 except:

db.close()
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

0 Answers0