Results 1 to 35 of 35

Thread: Find a certian link

  1. #1

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Find a certian link

    Well, this actually turned out to be hard, and I seriously dont know of a way to do this. Ok, so I have a program that will take text entered by the user, insert it in some textboxes on a webpage, then submit and dozens of links will come back. Now all the liinks are in order, and I need to get the first one. Whats really hard, is its not like its the samething everytime. I just need to get to the first link somehow and click it. I tryed a couple ways, but all of them turned out to not work. Is there a way of doing this in Vb?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Find a certian link

    Couldn't you simply parse the HTML document and search for the first anchor element and then navigate to the destination?

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Find a certian link

    Could you post your code?

    I think it might look something like this....
    VB Code:
    1. Dim oLink as HTMLAnchorElement
    2. Set oLink = Webbrowser.Links(0)
    3. oLink.Click
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Yea, but wouldn't that be the first link on the page? Because there are like ads and stuff also, not just the searched link.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Find a certian link

    2 words for you - DOM Inspctor. It comes with Firefox.

  6. #6
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    instead find what tags its inside, or something of the like, and replace the code around it

  7. #7

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Yea, I know what you mean with the tags an all, but wouldn't they change when the link changes? I dont know about Dom Inspector though, never found it, Im just using an html editor on the page and viewing all the stuff. But, the link always changes, its never the same, so I dont think you can call the same tag.

  8. #8

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    So does anyone know how I can do this? If you guys wanna see the page, just ask, but im sure most of you can't, since you have to have an account.

  9. #9
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    give me the site and ill show you an example

  10. #10

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Alright, here is an example page. What I mean, is the page yes looks like that, but the shown links vary to which item you searched for, and what price. Here:
    http://www.neopets.com/market.phtml

    There, thats an example. See all the links in that framed kinda box, I want to goto that link each time.

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Find a certian link

    Quote Originally Posted by Inuyasha1782
    Yea, I know what you mean with the tags an all, but wouldn't they change when the link changes? I dont know about Dom Inspector though, never found it, Im just using an html editor on the page and viewing all the stuff. But, the link always changes, its never the same, so I dont think you can call the same tag.
    I guess that I installed it, but I don't know when. Someone suggested using it, and it was there! I thought it came with Fx, but just looked and found this:

    https://addons.mozilla.org/extension...nfo.php?id=434

  12. #12

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    How do you install it >< All I saw was "THIS CRASHES YOUR FIREFOX", and some other stuff. Would you happen to know?

  13. #13
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    well, see that just doesnt make sense. Those links are going to be the same place everytime. Explain this again

  14. #14

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    What do you mean? Yes, they will be the same place, but there not the same link. Everything in there is in the same place, but just randomly changes. Why is there an easy way to do it?

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Find a certian link

    I have 6 extensions that I downloaded with v 1.0 of Fx. Maybe it came with the DOM Inspector? Oh. Now I see what happened.
    In addition, the Mozilla DOM Inspector is very useful in trying to figure out what properties to set. This can be added to Firefox by going checking the DOM Inspector checkbox during a custom installation.
    I guess I'd try to install from the link, and if it crashes, do a custom install

  16. #16

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Ok, so |2em!x do you know how to get about what im doing?

    Btw, it crashed it :/ Ill have to do a custom.

  17. #17
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    Code:
    <area shape=rect coords="0,10,130,53" href=/addpet.phtml onmouseover="sh(1)" alt="Create a Neopet">
    <area shape=rect coords="0,53,130,104" href=/petcentral.phtml onmouseover="sh(2)" alt="Pet Central">
    <area shape=rect coords="0,104,130,137" href=/explore.phtml onmouseover="sh(3)" alt="Explore">
    <area shape=rect coords="0,137,130,169" href=/gameroom.phtml onmouseover="sh(4)" alt="Games">
    <area shape=rect coords="0,169,130,198" href=/neomessages.phtml onmouseover="sh(5)" alt="Neomail">
    
    <area shape=rect coords="0,198,130,231" href=/objects.phtml onmouseover="sh(6)" alt="Shops">
    <area shape=rect coords="0,231,130,265" href=/neoboards/index.phtml onmouseover="sh(7)" alt="Neoboards">
    <area shape=rect coords="0,265,130,299" href=/nf.phtml onmouseover="sh(8)" alt="News">
    <area shape=rect coords="0,299,130,335" href=/stuff.phtml onmouseover="sh(9)" alt="Stuff">
    <area shape=rect coords="0,335,130,368" href=/help.phtml onmouseover="sh(10)" alt="Help">
    <area shape=rect coords="0,368,130,397" href=/loginpage.phtml onmouseover="sh(11)" alt="Login">
    <area shape=rect coords="0,397,130,427" href=/logout.phtml onmouseover="sh(12)" alt="Logout"></map>
    see that? open the site with inet control, split it by vbcrlf, and if the line has an instr of <area shape=rect coords= add it to an array..Ill help you after you get that far

  18. #18

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    So, how do I open it and split?

  19. #19
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    VB Code:
    1. x = inet1.openurl("Neopetswebsite.com",icstring)
    2. dim cat() as string
    3. dim i as integer
    4. cat() = split(x,Vbcrlf)'this splits on everynew line
    5. For i = 0 to ubound(cat)
    6. If instr(cat(i),"<area shape=rect coords=") then
    7. textbox1.text = textbox1.text & cat(i)
    8. end if
    9. next i
    this will get all the sites, say something when you get this far

  20. #20

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Sorry for the late reply, been busy, but I have a newbie question lol. I know I need an inet control, but I forgot how to get to em. I know I need something because Im getting the object required error. Just forgot how to ><

  21. #21
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Find a certian link

    Project > Components > Microsoft Internet Transfer Control.

  22. #22

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Ok, so what do I do with that?

  23. #23
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    add it to your form, name it inet1, then follow my code.

  24. #24

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Yea, I already did that. I ment what do I do next with all that Html I got back. I know a little Html, but I cant exactly understand what I got back.

  25. #25

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    |2eM!x do you know? You said to tell you after I got that far. If you want I can post the Html I got back if you need. Or am I doing something wrong?

  26. #26
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    sorry i was at work, and i wrote the code wrong. give me a few minutes and it will be fixed

  27. #27
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    This will tell you the site, along with the button caption.
    VB Code:
    1. Option Explicit
    2. Dim cat() As String
    3. Dim i As Integer
    4. Dim x As String
    5.  
    6. Private Sub Form_Load()
    7. x = Inet1.OpenURL("http://www.neopets.com/market.phtml", icString)
    8.     cat() = Split(x, Chr(10)) 'this splits on everynew line
    9.         For i = 0 To UBound(cat)
    10.             If InStr(cat(i), "<area shape=rect coords=") Then
    11.                 Text1.Text = Text1.Text & cat(i)
    12.             End If
    13.         Next i
    14. i = 0
    15. Do Until InStr(Text1.Text, i) = 0
    16.     Text1.Text = Replace(Text1.Text, i, vbNullString)
    17.     i = i + 1
    18. Loop
    19.     Text1.Text = Replace(Text1.Text, "<area shape=rect coords=", vbNullString)
    20.     Text1.Text = Replace(Text1.Text, "onmouseover=" & Chr(34) & "sh()" & Chr(34), vbNullString)
    21.     Text1.Text = Replace(Text1.Text, """,,,""", vbNullString)
    22. cat() = Split(Text1.Text, "href=/")
    23.     For i = 0 To UBound(cat)
    24.         MsgBox ("http://www.neopets.com/market" & cat(i))
    25.     Next i
    26. End Sub

  28. #28

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Alright, first I need to test this on my prog. Except I cant specify a certian webpage. I need to do this with the current page I am on.
    So, how do I change "x = Inet1.OpenURL("http://www.neopets.com/market.phtml", icString)" that to make it so it opens to the current page I am on, well it cant really open like another type of browser either.
    See here is the problem, so say you goto search for the item. You type in all of the stuff and search. Now, when you search, no matter what the link will always be the same and be like "www.neopets.com/shopwiz/market" No matter what you search for. Now if you open that same link in another browser your just taken to the market main. So its not like I can get to the certian page via link, I have to tell it to search the page I am currently viewing. How do I do that?

  29. #29
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    i really dont understand what the heck your talking about..: /..ps i have to go to bed 2:30 am

  30. #30

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Alright, let me try to explain again. This whole thing is based around a search engine that searches for items. What I need to do, is search for the item, then goto the first link on the page. I already have the first part with searching for the item, just need the other part. So say I did this:
    1. Typed in an item to search for at "http://www.neopets.com/market.phtml?type=wizard"
    2. Clicked the search button, and got my results at "http://www.neopets.com/market.phtml"
    3. I did another search at the same place.
    4. Got different results at the same place last time which was "http://www.neopets.com/market.phtml"

    So no matter what I search for, the link will always be the same for my results.
    Now, your coding for the inetcontrol, is opening a link to search for the urls and there names. This cannot work since no matter what I search, the link will always be the same. So I cant do it for the specific item I want.
    So instead, I want to specify the current page I am on in my browser. So, I do a search, and get my results. That exact page, I want to run the inetcontrol on, and get the url names etc.
    Hope that helps some.

  31. #31
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Find a certian link

    yes...except i cant help you with this anymore..

  32. #32

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    Well, thanks for the help, does anyone else know how to do what I am saying?

  33. #33
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Find a certian link

    Sounds to me that you are loosing the session cookie which tracks the search..forget inet and go straight to an IE object - IE will handle all the cookies, etc, for you that way plus you'll have more direct access to the document object which will greatly simplify page parsing.

    Obviously, the values in the fields of this code won't be correct but it should give you an idea of how to get to the website, login, search and then find the link you are looking for

    VB Code:
    1. Set myIE = CreateObject("InternetExplorer.Application")
    2. myIe.Navigate "login url goes here"
    3. do while myIe.Busy
    4.     DoEvents
    5. loop
    6. ' replace "form" with the correct name of the login form
    7. ' and uname/password with the correct field names
    8. myIe.form.uname = "username goes here"
    9. myIe.password = "password goes here"
    10. myIe.form.t
    11. Do While myIe.Busy
    12.     DoEvents
    13. loop
    14.  
    15. ' fill in search box - again, replace "form" and "search"
    16. ' with the correct values to perform the search
    17. myIe.form.search = "search text goes here"
    18. myIe.form.submit
    19. Do While myIe.Busy
    20.     DoEVents
    21. loop
    22.  
    23. ' since, as you say, the link is always the same at this point,
    24. ' just navigate to the known url
    25.  
    26. myIe.Navigate "place the url here"
    27. Do While myIe.Busy
    28.     DoEvents
    29. Loop

    You should now be at the page you are trying to find

  34. #34

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    So that just gets me to the search page? Thats what it looks like. Could you explain it a little more? Because it looks like something different then what I need. I just need to goto the first link on the lists of links from the search results. It was just that the same link caused a problem.

  35. #35

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Find a certian link

    So I am beggining to think this is not possible? Ive been workin for awhile now, and I can't get it to inet on the page I am already on. I just don't know the command to even reconize it, so I could put like the cookie I am on in a variable. Does anyone else have any ways of doing this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width