Jump to content


Trouble With Regexp...

  • Please log in to reply
1 reply to this topic

#1 Donald.

  • Members
  • PipPip
  • Member
  • 19 posts

Posted 22 December 2012 - 04:34 AM

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

Edited by Donald., 22 December 2012 - 04:34 AM.

#2 Donald.

  • Members
  • PipPip
  • Member
  • 19 posts

Posted 23 December 2012 - 07:33 PM

I've figured it out. It was something with the website rather than my regexp...

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users