Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:55:36+00:00 2026-05-30T02:55:36+00:00

I’m trying to keep linebreaks reading from a txt file when I print the

  • 0

I’m trying to keep linebreaks reading from a txt file when I print the content into an HTML one.

I get results from boilerpipe in this way:

class BottomPipeResult :

    AGENT_ID   = "Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"

    BOTTOMPIPE_URL = "http://boilerpipe-web.appspot.com/extract?url={0}&extractor=LargestContentExtractor&output=text"

    #BOTTOMPIPE_URL = "http://boilerpipe-web.appspot.com/extract?url={0}&extractor=ArticleExtractor&output=htmlFragment"

    _myBPPage = ""

    # scrape and get results from bottompipe
    def scrapeResult(self, theURL, user_agent=AGENT_ID) :
        request = urllib2.Request(self.BOTTOMPIPE_URL.format(theURL))
        if user_agent:
            request.add_header("User-Agent", user_agent)
            pagefile = urllib2.urlopen(request)
            realurl = pagefile.geturl()
            f = pagefile
            self._myBPPAge = f.read()
        return(self._myBPPAge) 

but when I reprint them to html I loose all the linebreaks.

Here’s the code I use to write into HTML

f = open('./../../entries-new.html', 'a')
f.write(BottomPipeResult.scrapeResult(myLinkResult))
f.close()

Here an example of booilerpipe text result:

http://boilerpipe-web.appspot.com/extract?url=http%3A%2F%2Fresult.com&extractor=ArticleExtractor&output=text

i tried this but it doesn’t work:

myLinkResult = re.sub('\n','<br />', myLinkResult)

Any suggestion?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:55:37+00:00Added an answer on May 30, 2026 at 2:55 am

    I modified your code just a touch so it was runnable and it seems to “work” properly for me. The resulting output has line endings where expected. I’m seeing some encoding issues, but no line ending issues.

    Code

    import urllib2
    
    class BottomPipeResult :
    
        AGENT_ID   = "Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
        BOTTOMPIPE_URL = "http://boilerpipe-web.appspot.com/extract?url={0}&extractor=LargestContentExtractor&output=text"
        _myBPPage = ""
    
        # scrape and get results from bottompipe
        def scrapeResult(self, theURL, user_agent=AGENT_ID) :
            request = urllib2.Request(self.BOTTOMPIPE_URL.format(theURL))
            if user_agent:
                request.add_header("User-Agent", user_agent)
                pagefile = urllib2.urlopen(request)
                realurl = pagefile.geturl()
                f = pagefile
                self._myBPPAge = f.read()
            return(self._myBPPAge) 
    
    
    bpr = BottomPipeResult()
    myLinkResult = 'http://result.com'
    
    f = open('out.html', 'a')
    f.write(bpr.scrapeResult(myLinkResult))
    f.close()
    

    Output

    Result-Expand.flv
    We want to help your company grow. Our Result offices around the world can help you expand your business faster and more cost efficiently. And at the same time bring the experience of having expanded more than 150 companies during the past ten years.
    Result can help you grow in your local market, regionally, or globally through our team of experienced business builders, our industry know-how and our know-who.
    Our services range from well designed expansion strategies to assuming operational responsibility for turning these strategies into successful business.
    We don’t see ourselves as mere consultants  who give you a strategy presentation and then leave you to your own devices. We prefer to be considered as an extended, entirely practical arm of your management team. We’re hands-on and heads-on. We’re business builders.
    We’re co-entrepreneurs. This is also reflected in our compensation structure – a significant part of our compensation is result  based.
    

    Making the results more “HTML” like

    As far as html output is concerned, you probably want to wrap each line in a <p> paragraph tag.

    output = BottomPipeResult.scrapeResult(myLinkResult) 
    f.write('\n'.join(['<p>' + x + '</p>' for x in output.split('\n')]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.