Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Realbasic > Re: Modifying a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 3313 of 3326
Post > Topic >>

Re: Modifying all URLs in a string

by "Auric__" <not.my.real@[EMAIL PROTECTED] > May 8, 2008 at 04:18 PM

On Thu, 08 May 2008 14:09:52 GMT, Allan Drake wrote:

> I am modifying URLs for amazon products in a string along with
> other html data in a real basic script. I can't find the right way
> to do it. 
>
> An Example URL:
> http://www.amazon.com/exec/obidos/ASIN/B0013EF17O/ref=br_nf_0_4?pf_r
> d_p=369756201&pf_rd_s=center-11&pf_rd_t=101&pf_rd_i=496994&pf_rd_m=A
> TVPDKIKX0DER&pf_rd_r=0N5NC0HECYSPF2G37FPK 
>
>
> After  "/ASIN/B0013EF17O/" I want to insert my standard amazon
> affiliate code    so it would be like....
>
> /ASIN/B0013EF170/**myaffiliatecodehere***/   <---> chop off the
> rest of the URL
>
>
> So I am basically, searching, inserting my code in the right spot,
> and then chopping off part of the URL. I need to do this for every
> link in my string.

(If my "solutions" don't help, you might want to ask in a more general 
group, like alt.basic or comp.lang.basic.misc.)

Assuming that you want to remove everything after the last "/", and 
"/" is never part of the stuff to be removed, just search for the last 
occurance of "/".

(I'm out of practice with RB; this is untested VB6-style air code.)
  function insert_my_crap(url as string) as string
    tmp& = instr(-1, url, "/") ' or instrrev, if available
    l$ = left$(url, tmp&) & "myaffiliatecode"
    function = l$
  end function

Alternately, if the product number is always a certain number of 
levels deep (I don't use Amazon -- evil -- so I don't know), you can 
count the correct number of "/"s and work from there:

  function insert_my_crap_2(url as string) as string
    for loop0 = 1 to number_of_slashes_to_look_for
      tmp& = instr(tmp& + 1, url, "/")
    next
    l$ = left$(url, tmp&) & "myaffiliatecode"
    function = l$
  end function

I'm sure you could figure out something else to look for, if needed. 
(These all assume that Amazon is consistent about such things. YMMV.)

-- 
Be good and get on the hook.
 




 7 Posts in Topic:
Modifying all URLs in a string
Allan Drake <supercool  2008-05-08 07:09:52 
Re: Modifying all URLs in a string
Allan Drake <supercool  2008-05-08 07:12:27 
Re: Modifying all URLs in a string
"Auric__" <n  2008-05-08 16:18:25 
Re: Modifying all URLs in a string
John <jmrukkers@[EMAIL  2008-05-09 06:46:19 
Re: Modifying all URLs in a string
Allan Drake <supercool  2008-05-12 14:43:49 
Re: Modifying all URLs in a string
"Rick Rothstein \(MV  2008-05-19 02:59:36 
Re: Modifying all URLs in a string
"Rick Rothstein \(MV  2008-05-19 03:02:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:39:44 CDT 2008.