Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract price from sold eBay page

Status
Not open for further replies.

mmerlinn

Programmer
May 20, 2005
748
US
[ ]

The following is a cut & pasted extract from the source of an eBay page for one of my sold items.


<tr bgcolor="#eeeef8">

<td width="5"><img src=" width="10" height="1"></td>

<td width="28" height="28" valign="top"><img src=" width="28" height="28" alt="Green Check"></td>

<td width="10"><img src=" width="10" height="1"></td>

<td colspan="2" valign="bottom" width="100%"><span class="sectiontitle"><b>
Your item sold for US $44.99!
</b></span><br>
Buyer's Postal Code: 75662<br></td>

<td width="10"><img src=" width="10" height="1"></td>

<td width="5"><img src=" width="10" height="1"></td>

</tr>


I want to extract the info in red, then pass that info to a different page when the buyer clicks a link on the returned page. I know how to pass the info to a different page. I don't know how to extract it from the returned page.

Limitations:

1) eBay writes the above code - I cannot change it.
2) eBay does not allow server side includes nor the EVAL function - I cannot call an off-page program nor file.
3) All code to do this must reside on the eBay page (client side) when the page is listed - no changes can be made after the sale.

Is it possible to do this?

Link to page that above was extracted from:




mmerlinn


"Political correctness is the BADGE of a COWARD!"
 
I'm no expert, but I'd probably start with an iframe. The src property would link the contents of the iframe to the contents of the page. Then you can search the contents of the iframe as a string and find the data you want with a regular expression.

Let's say you had an iframe all set up. You'd get the contents like:
Code:
var str1=document.getElementById("if1").contentWindow.document.body.innerHTML
where if1 would be the ID of your iframe.

Then your regular expression (for the "your item sold..." part) would be
Code:
re=/(your item sold for us \$)(\d+\.\d{2})(\!)/i
a=str1.match(re)

Now a[2] is equal to 44.99

and so on.

_________________
Bob Rashkin
 
[&nbsp;]

The problem with using iframe is that I have no idea which browser the buyer would be using. If the buyer is not using a browser supporting iframes, then they would not work.

Also, if I read you correctly, the buyer must already have an iframes page setup somewhere to make your solution work. Unfortunately, almost 100% of buyers are javascript and iframes illiterate.

Ideally, the extraction needs to work in all browsers. Otherwise I would need to serve up different pages depending on browser.

mmerlinn


"Political correctness is the BADGE of a COWARD!"
 
I don't understand. Are you going to ship a script to the buyer?

_________________
Bob Rashkin
 
[&nbsp;]

No.

I am going to create before (what I have) and after (what I want) sample listings and post them. However, for some odd reason I am unable to cut & paste from an eBay page here, so that will have to wait until I get to a computer that I can create the pages on.

mmerlinn


"Political correctness is the BADGE of a COWARD!"
 
[&nbsp;]

Here is what needs to happen:

1) I create the eBay auction page including embedded extraction code, then upload the page to eBay.

2) Buyer agrees to buy item.

3) eBay adds the final price to the auction page creating a non-changeable archive page.

4) Buyer clicks the ordering link on the new archive page.

5) Embedded extraction code extracts the final price from the archive page and appends it to the ordering link.

6) Ordering link passes final price to order page.

7) Order page processes final price adding the final price to the ordering page and adds S&H for a total amount due.

8) Buyer prints out page and sends it with money to me.

Currently, because I don't know how to extract the final price from the archive page, the buyer must manually fill in the final price on the order form and do the totalling himself.

I only have this problem with auction pages because I do not know the final value until after the auction ends.

On my buy-it-now pages I simply hardcode the final price into the ordering link and pass it to the order form.

As soon as I can I will get real-life samples posted.

mmerlinn


"Political correctness is the BADGE of a COWARD!"
 
OK. I'm out of my depth, then. There's probably a way to "scrape" the text on a given page but I don't know what it is.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top