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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:53:25+00:00 2026-06-15T06:53:25+00:00

I’m just starting out with BeautifulSoup and I’m trying to make a script that

  • 0

I’m just starting out with BeautifulSoup and I’m trying to make a script that will go to a number very similar pages and then return all of the paragraphs underneath a section. Currently I have the following code

def BrightstormPageTest():
    soup = Soup(urllib.urlopen('http://brightstorm.com/science/chemistry/chemical-reaction-rates/collision-theory/').read())
    relevantTagText = ""
    for element in soup.findAll("section"):
            print element.nextSibling

Which works great for the first paragraph, but there are two sections that I want the siblings from and the first section will always have exactly one paragraph, while the second will have an undetermined number somewhere between 1 and 10 probably. Any ideas on how to do this?

Relevant html:

<section>
      <div class="page-header">
       <h2>
        Explanation
       </h2>
      </div>
     </section>
     <p>
      <strong>
       Collision theory
      </strong>
      is a model for explaining chemical reactions and reaction rates using the interactions of particles within the reactants. There are three important parts to
      <strong>
       collision theory
      </strong>
      , that reacting substances must collide, that they must collide with enough energy and that they must collide with the correct orientation. Increasing the kinetic energy of these particles or decreasing their volume increases the frequency of collisions and speeds a reaction.
     </p>
     <section>
      <div class="page-header">
       <h2>
        Transcript
       </h2>
      </div>
     </section>
     <p>
      Alright so we're going to talk about the collision theory. And the collision theory comes into play when you're talking about reactions and actually what happens in a reaction and how a reaction actually goes from the reactant all the way to the product. So the first thing we're going to have to discuss is, the fact that the reacting substances whatever we're dealing with the atoms, ions or molecules must collide in order for the reaction to occur. Okay that seems pretty obvious so we have our 2 reactants a and b and they must collide, and this is what we're going to call activated complex or a transition states that's going from, transitioning from the reactants towards the product and it's going to recreate this independent, very high energy activated complex and then yield our products, our 2ab. So the first postulate is that they must come together, okay that's easy enough.
     </p>
     <p>
      The second one says the reactant substances must collide with sufficient energy in order to form that activated complex. Because this activated complex is extremely high, very high in energy, very unstable so they must collide with a certain amount of energy to get to this point. If they don't collide with a good amount of energy then they're actually not going to react at all. So that energy is going to be called our activation energy to get to our activated complex. And you might see the symbol e with a subscript a to note that. And the last thing in the collision theory is that reacting substances must collide with the correct orientation so if they, made a collision at a range that wasn't great for them, they would actually rebound off of each other and not react at all.
     </p>
     <p>
      But if they if they did they have to make sure they line up correctly and then for the correct reaction to occur then they get their activated complex to form the products. And so these 3 things are the basis of that collision theory and how reactants go from reactants to the products.
     </p>

Would like to just get the things inside these paragraphs.

  • 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-15T06:53:27+00:00Added an answer on June 15, 2026 at 6:53 am

    You need to iterate over the sections, then iterate over the paragraphs. I’ve modified your code to print the text of each paragraph for demonstration purposes.

    from bs4 import BeautifulSoup as Soup
    
    def BrightstormPageTest():
        soup = Soup(urllib.urlopen('http://brightstorm.com/science/chemistry/chemical-reaction-rates/collision-theory/').read())
        sections = soup.findAll("section")
        for section in sections:
            ps = section.findAll("p")
            for p in ps:
                print p.text
    
    def BrightstormPageTest2():
        soup = Soup(urllib.urlopen('http://brightstorm.com/science/chemistry/chemical-reaction-rates/collision-theory/').read())
        sections = soup.findAll("section")
        for section in sections:
            while True:
                 try:
                     print section.nextSibling.text
                 except TypeError:
                     # .text is a valid method on a <p> element, but not a NavigableString.  
                     break
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.