1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Page ranking optimization via ASP script

Discussion in 'C#' started by shlomot, Dec 28, 2005.

  1. #1
    Happy New Year to all.

    Let's take http://www.topsynergy.com/famous/Pamela_Anderson.asp as an example.

    Due to the shared top and left borders, the keyword “Pamela Anderson” is not included within the first 25 words of the visible text. It can be done if for example I'll replace the words "Relationships Analyst" that are boxed above the left-side menu options with "Pamela Anderson".

    I have over a thousand pages like this.

    If I'll have an include file where I CASE different scenarios of strings that are showing in the URL - it will do; or maybe you have a better solution.

    So the CASE will look something like that:

    CASE url includes "Pamela_Anderson"
    variable="Pamela Anderson"
    CASE url includes "Demi_Moore"
    variable="Demi Moore"
    ...
    END CASE
    WRITE variable

    The only problem is that I don't have a clue on how to put all of that together and with the right syntax. I am less than a novice ASP programmer.

    Can you please help?

    Thanks a bunch,
    shlomot
     
    shlomot, Dec 28, 2005 IP
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if your urls are all formatted exactly the same way, i.e. your url/famous/Pamela_Anderson.asp for Pamela Anderson,
    and by deduction
    your url/famous/Demi_Moore.asp for Demi Moore,
    and thus:
    your url/famous/Drew_Barrymore.asp for Drew Barrymore etc.... then you could get away with doing this little bit of trickery:

    
    'grab everything after the .com: i.e. "/famous/Pamela_Anderson.asp"
    urlname = request.servervariables("url")
    'determine the length of above variable
    urllength = len(urlname)
    'strip out the /famous/
    urlstripped = mid(urlname, 9, urllength)
    'determine the location of the "." to remove the extension
    extensionstripper = instr(aurl, ".")
    'finally, create a variable by replacing the "_" with " " and removing the .asp:
    yourvariable = replace(mid(urlstripped, 1, extensionstripper -1),"_", " ")
    
    'then - just use the variable as you see fit. i.e.
    response.write yourvariable
    'or 
    response.write "<title>" & yourvariable &"</title>"
    'etc... this part's up to you :D
    
    Code (markup):
    this would allow you to dynamically do what you're considering doing by hard-coding a "select case" statement.

    if your urls are formatted differently, i.e. you have some files in another directory such as "/infamous/ instead of "/famous/", you can still accomplish this by adding another line of code or two - but i don't know what kind of directory structure or naming convention you're using. I'm just guessing.

    :D

    VG
     
    vectorgraphx, Dec 28, 2005 IP
  3. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mod_rewrite

    Learn regexp. It's worth the google search and the effort. Really.
     
    jimrthy, Dec 28, 2005 IP
  4. shlomot

    shlomot Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Dear vectorgraphx,

    Your idea is great! Just my URLs are not that consistent (it can be /famous/ or /famous-news/, etc.) However, filenames are consistent and include the celebrity name in the Celebrity_Name.asp format.

    I modified your script to what is listed below, and that's all I have on the page. I only get HTML 500 error code. What am I doing wrong? Should I declare the variables first?

    <body>
    <!-- Extracting Page Theme -->
    <%
    ' Getting URL string
    urlname = request.servervariables("url")

    ' Stripping out portions befor file name
    do while instr(urlname, "/") > 0
    urlname = mid(urlname, instr(urlname, "/") +1, len(urlname))
    end do

    ' Stripping out file extention
    urlname = mid(urlname, 1, instr(urlname, ".") -1)

    ' Replace the "_" with " "
    theme = replace(mid(urlname, 1, len(urlname)), "_", " ")

    ' Write variable content
    response.write "<p>" & theme &"</p>"
    %>
    </body>
     
    shlomot, Dec 28, 2005 IP
  5. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    shlomot,

    try changing "end do" to "loop".

    You've taken my idea and taken it to the next level - that's exactly what i meant when i said you could modify a couple of lines of code and have the preceding directory name be of variable lengths.

    :D kudos!

    VG
     
    vectorgraphx, Dec 29, 2005 IP
  6. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #6

    unfortunately - though mod_rewrite is way cool - i doubt he has access to it. I'm assuming he's on a windows server using IIS, given that he's using asp classic... and to my knowledge mod_rewrite doesn't work in that environment (unfortunately, since i work in that environment almost exclusively).

    Dangit - yet another reason why i'm eventually going to have to learn another programming language.... hehe :D

    VG
     
    vectorgraphx, Dec 29, 2005 IP
  7. shlomot

    shlomot Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Dear VectorGraphx,

    Thanks again. Everything works fine with loop.

    And jimrthy, I thank you for your suggesstion. I'm sure it's a good one. However, I have no clue as to what to do with it, even after spending about an hour reading about the great regexp. I guess I'll leave it to true programmers :)

    Happy New Year to you all,
    shlomot
     
    shlomot, Dec 29, 2005 IP
  8. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #8
    no problem man - its an easy mistake. Getting the syntax right on all the various loops is kinda like trying to conjugate German verbs :D
     
    vectorgraphx, Dec 29, 2005 IP
  9. shlomot

    shlomot Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    For German verbs I challange Google Translation to do the job :)
     
    shlomot, Dec 29, 2005 IP
  10. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Given that this is an ASP site, probably on IIS, as vectorgraphx so gently pointed out, my idea was about as stupid as they get.

    Regexp's are great for when you need to change text (or file names) that you can figure out a pattern for. Kind of like the basic search & replace that shows up everywhere, except you can do some wicked-cool pattern definitions.

    Then again, a lot of "real programmers" absolutely hate them.
     
    jimrthy, Dec 29, 2005 IP