Jump to content

Recommended Posts

Hey guys, I'm back for more help. I haven't been here in a while since I was busy with college but now that finals are over I can once again get going with little things I do. As a side project I'm scraping some data online and I'm having a ton of trouble getting a hold of the price.

 

I've tried countless possibilities on how to get it, but I can't seem to grab it.

 

Here's part of the HTML section of the contents I'm trying to scrape. In this case I'd want the 6.58

<div class="item-block-top">
<h3>
$6.58 <span style="float: right; color: #8BD442">
<img src="/static/images/icon/up.png" /> 0.76% </span>
</h3>
<div class="item-details">Helm: +31% Extra Gold from Monsters<br>
Weapon: Critical Hit Damage Increased by 100%<br>
Other: +58 Dexterity<br>
<br>
Item Level: 66</div>
</div>

 

I'm using python with the BeautifulSoup extension... Here's the section of my code relevant to the price. I've already managed to get several other information on the items im scraping but the price is giving me headaches.

 

# Grab the price to the price of the item using REGEX
priceString = '<<I REALLY DONT KNOW WHAT TO PUT HERE ANYMORE>>'
FinderPrice = re.compile(priceString)
# Store all of the prices found
findPrice = re.findall(FinderPrice,webpage)

 

I even tried getting all of the content inside the <h3> tags and that still gives me a blank result. I was thinking that maybe it's because there is a $ character and that signals the end(?).

priceString = '<h3>(.*)</h3>'

 

 

Any help is really appreciated.

Thanks,

Donald.

Edited by Donald.
Link to comment
https://forums.phpfreaks.com/topic/272275-trouble-with-regexp/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.