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 8714025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:29:23+00:00 2026-06-13T05:29:23+00:00

I have started to learn how to scrape information from websites using urllib and

  • 0

I have started to learn how to scrape information from websites using urllib and beautifulsoup. I want to grab all the text from this page (in the code) and put it into a text file.

import urllib
from bs4 import BeautifulSoup as Soup
base_url = "http://www.galactanet.com/oneoff/theegg_mod.html"



url = (base_url)
soup = Soup(urllib.urlopen(url))

print(soup.get_text())

When I run this it grabs the text although it outputs it with spaces between all the letters and still shows me HTML, unsure why though.

i   n   '   >      Y   u   p   .       B   u   t       d   o   n      t       f   e   e        

Like that, any idea’s?

Also what would I do to put this info into a text file for me?

(Using beautifulsoup4 and running ubuntu 12.04 and python 2.7)

Thank you 🙂

  • 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-06-13T05:29:24+00:00Added an answer on June 13, 2026 at 5:29 am

    I had some trouble with the encoding, so I changed your code slightly, then added the piece to print the results to a file:

    import urllib
    from bs4 import BeautifulSoup as Soup
    
    base_url = "http://www.galactanet.com/oneoff/theegg_mod.html"
    
    url = (base_url)
    content = urllib.urlopen(url)
    soup = Soup(content)
    # print soup.original_encoding
    theegg_text = soup.get_text().encode("windows-1252")
    
    f = open("somefile.txt", "w")
    f.write(theegg_text);
    f.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

greetings, today i have started to learn java using netbeans ide. i would like
I have recently started to learn Objective-C and write my tests using OCUnit that
I started to learn PHP and have to find a mistake (maybe in this
I have just started to learn the very basics of Java programming. Using a
I have started to learn ASP.NET MVC, and at this time of studying I
I have recently started to learn using of Doctrine 2.0 framework for PHP. Now
I have started learning Haskell from Learn You a Haskell . In one of
i have started to learn ioctl i got this example http://tldp.org/LDP/lkmpg/2.6/html/x892.html i got total
I want to learn GWT, so I downloaded the GWT and have started to
I have just started to learn asp.net MVC3 and i run into this problem:

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.