here is the write part: out = open("test.txt", 'a') out.write (store+ food+ price + "\n") out.close()
Steven D'Aprano wrote: > On Mon, 26 Dec 2005 17:44:43 -0800, homepricemaps wrote: > > > sorry guys, here is the code > > > > for incident in bs('a', {'class' : 'price'}): > > price = "" > > for oText in incident.fetchText( oRE): > > price += oText.strip() + "','" > > > > for incident in bs('div', {'class' : 'store'}): > > store = "" > > for oText in incident.fetchText( oRE): > > store += oText.strip() + "','" > > > > for incident in bs('h2', {'id' : 'food'}): > > food = "" > > for oText in incident.fetchText( oRE): > > food += oText.strip() + "','" > > > This is hardly all your code -- where is the part where you actually > *write* something to the file? The problem is you are writing the same > store and food to the file over and over again. After you have collected > one line of store/food, you must write it to the file immediately, or at > least save it in a list so you can write the lot at the end. > > > -- > Steven. -- http://mail.python.org/mailman/listinfo/python-list