Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
Thanks Mandaar. On Apr 24, 2015 3:15 PM, "Mandar Vaze / मंदार वझे" wrote: > If you use "with" context manager then you don't have to explicitly close > the file handle. > > e.g. > > with open("filetosave","w") as fh: > for article in Sc_paper.articles: > fh.write(article) > > > > -Man

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Mandar Vaze / मंदार वझे
If you use "with" context manager then you don't have to explicitly close the file handle. e.g. with open("filetosave","w") as fh: for article in Sc_paper.articles: fh.write(article) -Mandar On Fri, Apr 24, 2015 at 2:18 PM, Prince Sharma wrote: > No problem, however i forgot to

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Prince Sharma
No problem, however i forgot to close the file handle. You can start solving problem from there ;) Cheers, Prince On Fri, Apr 24, 2015 at 2:05 PM, Nimish Dalal wrote: > On Fri, Apr 24, 2015 at 1:44 PM, Prince Sharma > wrote: > > > As mentioned you can create a list of all the URLs. > > > > Som

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
On Fri, Apr 24, 2015 at 1:44 PM, Prince Sharma wrote: > As mentioned you can create a list of all the URLs. > > Something like: > > > import newspaper > > fh = open("filetosave","w") > > Sc_paper = newspaper.build(u'http://scroll.in/') > > for article in Sc_paper.articles: > print(article.u

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Prince Sharma
As mentioned you can create a list of all the URLs. Something like: import newspaper fh = open("filetosave","w") Sc_paper = newspaper.build(u'http://scroll.in/') for article in Sc_paper.articles: print(article.url) fh,write(str(article.url)) http://scroll.in/.

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
On Fri, Apr 24, 2015 at 1:26 PM, Dhawal Joharapurkar wrote: > import newspaper > outfile = open('outfile.txt', 'a+) # Create a file handle > > Sc_paper = newspaper.build(u'http://scroll.in/') > for article in Sc_paper.articles: > print(article.url) > outfile.write(article.url) # Write t

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Dhawal Joharapurkar
import newspaper outfile = open('outfile.txt', 'a+) # Create a file handle Sc_paper = newspaper.build(u'http://scroll.in/') for article in Sc_paper.articles: print(article.url) outfile.write(article.url) # Write to file outfile.write('\n') outfile.close() # Close the file handle T

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
On Fri, Apr 24, 2015 at 12:48 PM, sshabin...@gmail.com wrote: > -OR- > > import newspaper > > articles = [ ] > Sc_paper = newspaper.build(u'http://scroll.in/') > > for article in Sc_paper.articles: > articles.append(article) > > with open("filename", "w") as f: > f.write( "\n".join(articl

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
On Fri, Apr 24, 2015 at 12:29 PM, Prince Sharma wrote: > By export you mean you want to create a text file for every URL? > Hey Prince, I want all the urls to be compiled in a text file. Hi, I am new to python and need help with newspaper. > I am using this module as I find it easier to extract

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Nimish Dalal
On Fri, Apr 24, 2015 at 12:21 PM, Dhawal Joharapurkar wrote: > This is a simple problem. > > 1. Create a file handle. > 2. Write to the file using the file handle. > 3. Close the file handle. > > import newspaper > outfile = open('outfile.txt', 'a+) # Create a file handle > > Sc_paper = newspape

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread sshabin...@gmail.com
-OR- import newspaper articles = [ ] Sc_paper = newspaper.build(u'http://scroll.in/') for article in Sc_paper.articles: articles.append(article) with open("filename", "w") as f: f.write( "\n".join(articles) ) On Fri, Apr 24, 2015 at 12:29 PM, Prince Sharma wrote: > By export you mean

Re: [BangPypers] Newspaper in Python

2015-04-24 Thread Prince Sharma
By export you mean you want to create a text file for every URL? Hi, I am new to python and need help with newspaper. I am using this module as I find it easier to extract the urls from the website. Here's my code: import newspaper Sc_paper = newspaper.build(u'http://scroll.in/') for article in S

Re: [BangPypers] Newspaper in Python

2015-04-23 Thread Dhawal Joharapurkar
This is a simple problem. 1. Create a file handle. 2. Write to the file using the file handle. 3. Close the file handle. import newspaper outfile = open('outfile.txt', 'a+) # Create a file handle Sc_paper = newspaper.build(u'http://scroll.in/') for article in Sc_paper.articles: print(articl

[BangPypers] Newspaper in Python

2015-04-23 Thread Nimish Dalal
Hi, I am new to python and need help with newspaper. I am using this module as I find it easier to extract the urls from the website. Here's my code: import newspaper Sc_paper = newspaper.build(u'http://scroll.in/') for article in Sc_paper.articles: print(article.url) http://scroll.in/... htt