Re: [Tutor] scraping and saving in file

2010-12-30 Thread Patrick Sabin
On 2010-12-29 10:54, Tommy Kaas wrote: It works fine but besides # I also get spaces between the columns in the text file. How do I avoid that? You could use the new print-function and the sep keyword argument, e.g.: from __future__ import print_function f = open("filename", "w") print("1", "

Re: [Tutor] scraping and saving in file SOLVED

2010-12-29 Thread Stefan Behnel
Peter Otten, 29.12.2010 13:45: File "/usr/lib/pymodules/python2.6/BeautifulSoup.py", line 430, in encode return self.decode().encode(encoding) Wow, that's evil. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscrip

Re: [Tutor] scraping and saving in file SOLVED

2010-12-29 Thread Peter Otten
Tommy Kaas wrote: > With Stevens help about writing and Peters help about import codecs - and > when I used \r\n instead of \r to give me new lines everything worked. I > just thought that \n would be necessary? Thanks. > Tommy Newline handling varies across operating systems. If you are on Windo

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Tommy Kaas wrote: Steven D'Aprano wrote: But in your case, the best way is not to use print at all. You are writing to a file -- write to the file directly, don't mess about with print. Untested: f = open('tabeltest.txt', 'w') url = 'http://www.kaasogmulvad.dk/unv/

[Tutor] scraping and saving in file SOLVED

2010-12-29 Thread Tommy Kaas
on.org > [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På > vegne af Peter Otten > Sendt: 29. december 2010 11:46 > Til: tutor@python.org > Emne: Re: [Tutor] scraping and saving in file > > Tommy Kaas wrote: > > > I’m trying to learn basic web scr

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Peter Otten
Tommy Kaas wrote: > Steven D'Aprano wrote: >> But in your case, the best way is not to use print at all. You are >> writing > to a >> file -- write to the file directly, don't mess about with print. >> Untested: >> >> >> f = open('tabeltest.txt', 'w') >> url = 'http://www.kaasogmulvad.dk/unv/pyt

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Tommy Kaas
Steven D'Aprano wrote: > But in your case, the best way is not to use print at all. You are writing to a > file -- write to the file directly, don't mess about with print. Untested: > > > f = open('tabeltest.txt', 'w') > url = 'http://www.kaasogmulvad.dk/unv/python/tabeltest.htm' > soup = Beautif

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Peter Otten
Tommy Kaas wrote: > I’m trying to learn basic web scraping and starting from scratch. I’m > using Activepython 2.6.6 > I have uploaded a simple table on my web page and try to scrape it and > will save the result in a text file. I will separate the columns in the > file with > #. > It works fin

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Knacktus
Am 29.12.2010 10:54, schrieb Tommy Kaas: Hi, I’m trying to learn basic web scraping and starting from scratch. I’m using Activepython 2.6.6 I have uploaded a simple table on my web page and try to scrape it and will save the result in a text file. I will separate the columns in the file with #.

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Steven D'Aprano
Tommy Kaas wrote: I have uploaded a simple table on my web page and try to scrape it and will save the result in a text file. I will separate the columns in the file with #. It works fine but besides # I also get spaces between the columns in the text file. How do I avoid that? The print comm

[Tutor] scraping and saving in file

2010-12-29 Thread Tommy Kaas
Hi, I’m trying to learn basic web scraping and starting from scratch. I’m using Activepython 2.6.6 I have uploaded a simple table on my web page and try to scrape it and will save the result in a text file. I will separate the columns in the file with #. It works fine but besides # I also get