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

  • Home
  • SEARCH
  • 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 6959131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:13:56+00:00 2026-05-27T15:13:56+00:00

I am trying to scrape some content (am very new to Python) and I

  • 0

I am trying to scrape some content (am very new to Python) and I have hit a stumbling block. The code I am trying to scrape is:

<h2><a href="/best-sellers/sj-b9822.html">Spear & Jackson Predator Universal Hardpoint Saw     - 22"</a></h2>
<p><span class="productlist_mostwanted_rrp">    
Was: <span class="strikethrough">£12.52</span></span><span class="productlist_mostwanted_save">Save: £6.57(52%)</span></p>

<div class="clear"></div>

<p class="productlist_mostwanted_price">Now: £5.95</p>

What I am trying to scrape is the link text (Spear & Jackson etc) and the price (£5.95). I have looked about on Google, the BeautifulSoup documentation and on this forum and I managed to get to extract the “Now: £5.95” using this code:

for node in soup.findAll('p', { "class" : "productlist_grid_price" }):
     print ''.join(node.findAll(text=True))

However the result I am after is just 5.95. I have also had limited success trying to get the link text (Spear & Jackson) using:

soup.h2.a.contents[0]

However of course this returns just the first result.

The ultimate result that I am aiming for is to have the results look like:

Spear & Jackson Predator Universal Hardpoint Saw - 22 5.95
etc
etc

As I am looking to export this to a csv, I need to figure out how to put the data into 2 columns. Like I say I am very new to python so I hope this makes sense.

I appreciate any help!

Many 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-27T15:13:57+00:00Added an answer on May 27, 2026 at 3:13 pm

    I think what you’re looking for is something like this:

    from BeautifulSoup import BeautifulSoup
    import re
    
    soup = BeautifulSoup(open('prueba.html').read())
    item = re.sub('\s+', ' ', soup.h2.a.text)
    price = soup.find('p', {'class': 'productlist_mostwanted_price'}).text
    price = re.search('\d+\.\d+', price).group(0)
    
    print item, price
    

    Example output:

    Spear & Jackson Predator Universal Hardpoint Saw – 22″ 5.95

    Note that for the item, the regular expression is used just to remove extra whitespace, while for the price is used to capture the number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote some basic Python code to scrape a remote webpage and grab a
I am trying to scrap some content from a website but the code below
I'm trying to scrape some content off another site and I'm not sure why
Trying out mechanize to scrape some content off an https asp site, it looks
I am trying to scrape some content from an HTML page. I'm using libxml2
I have a scraper, which queries different websites. Some of them varyingly use Content-Encoding.
I am trying to scrape some data from a page with a table based
I have been trying to get our software department to adopt some kind development
I am trying to use the HTML Agility pack to scrape some data from
I'm trying to scrape some pages, from a list on a text file, from

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.