i have the following code which is used to create a tuple of food and drink. if the page i am trying to scrape has a total of 10 food/drink items that i end up getting a nice list of 10 food/drink items in my text file BUT they are all a repeat of the first item so i end up getting a text file that looks like this:
shrimp, coke shrimp, coke shrimp, coke instead of being shrimp, coke hamburger, oj here is my code: for row in bs('div', {'style' : 'both'}): data=[] for incident in bs('h3', {'class' : 'name'}): foodlist = [] for oText in incident.fetchText( oRE): foodlist.append(oText.strip() + "','") food = ''.join(foodlist) for incident in bs('span', {'class' : 'drink'}): drink = incident.findNextSibling('a', {'class': 'nojs'}) drinklist = [] for oText in drink.fetchText( oRE): drinklist.append(oText.strip() + "','") drink = ''.join(drinklist) tuple = (food + drink + "\n") data.append(tuple) f = open("test.txt", 'a') f.write ( ''.join( tuple ) ) -- http://mail.python.org/mailman/listinfo/python-list