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 <prince0...@gmail.com> wrote: > 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 <nimish.s.da...@gmail.com> > wrote: > > > On Fri, Apr 24, 2015 at 1:44 PM, Prince Sharma <prince0...@gmail.com> > > 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.url) > > > > > > fh,write(str(article.url)) > > > > > > http://scroll.in/. <http://scroll.in/>.. > > > http://scroll.in/. <http://scroll.in/>.. > > > > > > > > Thank you Prince. That was helpful. > > > > I appreciate all you people who spared your time to resolve the issue. > > > > Someday I think I will be intelligent enuf to share my knowledge and > > resolve noob's problems. Haha.. > > > > > > > > > On Apr 24, 2015 1:20 PM, "Nimish Dalal" <nimish.s.da...@gmail.com> > > wrote: > > > > > > > On Fri, Apr 24, 2015 at 12:29 PM, Prince Sharma < > prince0...@gmail.com> > > > > 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 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/... > > > > > http://scroll.in/... > > > > > > > > > > Instead of print I want the urls to export as a .txt file or .csv > > > file. > > > > > > > > > > Thanks in advance. > > > > > > > > > > > > > > > -- > > > > > Nimish S. Dalal > > > > > Cell: 9819670499 > > > > > Facebook: http://www.facebook.com/nimish.s.dalal > > > > > Twitter: http://twitter.com/nimishdalal < > > > http://twitter.com/nimishsdalal > > > > > > > > > > Linkedin:http://in.linkedin.com/in/nimishsdll > > > > > Url: http://www.nimishdalal.me > > > > > > > > > > Our generation has had no Great Depression, no Great War. Our war > is > > a > > > > > spiritual war. Our great depression is our lives. > > > > > _______________________________________________ > > > > > BangPypers mailing list > > > > > BangPypers@python.org > > > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > _______________________________________________ > > > > > BangPypers mailing list > > > > > BangPypers@python.org > > > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > > > > > > > > > > > > > > > > > -- > > > > Nimish S. Dalal > > > > Cell: 9819670499 > > > > Facebook: http://www.facebook.com/nimish.s.dalal > > > > Twitter: http://twitter.com/nimishdalal < > > http://twitter.com/nimishsdalal > > > > > > > > Linkedin:http://in.linkedin.com/in/nimishsdll > > > > Url: http://www.nimishdalal.me > > > > > > > > Our generation has had no Great Depression, no Great War. Our war is > a > > > > spiritual war. Our great depression is our lives. > > > > _______________________________________________ > > > > BangPypers mailing list > > > > BangPypers@python.org > > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > > > _______________________________________________ > > > BangPypers mailing list > > > BangPypers@python.org > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > > > > > > > -- > > Nimish S. Dalal > > Cell: 9819670499 > > Facebook: http://www.facebook.com/nimish.s.dalal > > Twitter: http://twitter.com/nimishdalal <http://twitter.com/nimishsdalal > > > > Linkedin:http://in.linkedin.com/in/nimishsdll > > Url: http://www.nimishdalal.me > > > > Our generation has had no Great Depression, no Great War. Our war is a > > spiritual war. Our great depression is our lives. > > _______________________________________________ > > BangPypers mailing list > > BangPypers@python.org > > https://mail.python.org/mailman/listinfo/bangpypers > > > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers