I 'm trying to solve this question for 3 hours. Please can you tell me what is wrong? These are my codes
import urllib
from jin import HtmlMigrate
from bs4 import BeautifulSoup
import logging
list2=[]
logging.basicConfig( format='%(levelname)s:%(message)s', level=logging.INFO)
current = 1
source =""
for v in range(13960581, 13960585):
list=[]
try:
fil = urllib.urlopen(source+str(v))
fill = fil.read()
soup = BeautifulSoup(fill)
k = soup.find("div", "post-taglist")
for i in k.findAll("a"):
list.append(i.string)
except AttributeError:
pass
if "python" in list:
try:
a = soup.find( "div", "post-text")
list2.append(a)
logging.info("%s question localized." % str(current))
except AttributeError:
pass
current +=1
mig = HtmlMigrate()
out = file("stackover.html", "w")
for i in list2:
mig.run(i, out)
out.close()
The problem is that I get duplicated entries in the console for each logger.info call. How can I solve this?
list2coming from? How does this code even reach the logger when it should beNameErroring first?