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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:01:01+00:00 2026-06-02T05:01:01+00:00

I am reading some product pages in python/BS4 and find an interesting variety in

  • 0

I am reading some product pages in python/BS4 and find an interesting variety in one line of code, the price of the item.

Sometimes the HTML is:

<span class="currency">$<span id="product_price">0.00</span></span>

And other times it will be:

<span class="currency">$17.95</span></b>

Using price = soup.find('span', {'class' : 'currency'})

I can isolate the span, but when I try to get just the text, using

priceStr = price.findAll(text=re.compile(r''))

and then write it to the output file with

divpage.write('Price = ' + str(priceStr) + '\n')

I get (for the first example):

Price = [u'$', u'0.00']

My question is, is there a way to read JUST the price, without the ‘$’, and how do I translate the encoding from the “u’0.00′” to just “0.00”?

I know I can do this using the Python find & replace functions, but I’d like to stick to BSS4 as much as possible, without having to write w check for one form or the other…

  • 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-02T05:01:03+00:00Added an answer on June 2, 2026 at 5:01 am

    I would use get_text() instead of find_all()

    price_str = price.get_text() # $17.95
    

    Then you can use lstrip to get rid of the dollar sign

    price_str = price_str.lstrip('$') # 17.95
    

    And you’re done!

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

Sidebar

Related Questions

Reading some Verilog code, there seem to be two ways of defining arguments in
When reading some FreeBSD source code (See: radix.h lines 158-173), I found variable declarations
I did some fairly thorough reading and searching through SO and didn't find anything
Reading some questions here on SO about conversion operators and constructors got me thinking
Reading some posts from Jimmy Boggard and wondering - how exactly is it possible
After reading some material on this subject I'm still not sure what the difference
When reading some documentation about assertions, I found: java -ea -dsa Enables assertions in
After reading some articles about XSS I have incorporated HTMLPurifier into my zend framework
I'm reading some data for countries around the world and am playing with Google's
I was reading some old game programming books and as some of you might

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.