|
-
Jun 14th, 2005, 12:07 AM
#1
Thread Starter
Frenzied Member
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?
-
Jun 14th, 2005, 12:15 AM
#2
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?
-
Jun 14th, 2005, 12:16 AM
#3
Re: Find a certian link
Could you post your code?
I think it might look something like this....
VB Code:
Dim oLink as HTMLAnchorElement
Set oLink = Webbrowser.Links(0)
oLink.Click
-
Jun 14th, 2005, 12:23 AM
#4
Thread Starter
Frenzied Member
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.
-
Jun 14th, 2005, 12:47 AM
#5
Re: Find a certian link
2 words for you - DOM Inspctor. It comes with Firefox.
-
Jun 14th, 2005, 01:04 AM
#6
Re: Find a certian link
instead find what tags its inside, or something of the like, and replace the code around it
-
Jun 14th, 2005, 09:15 AM
#7
Thread Starter
Frenzied Member
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.
-
Jun 14th, 2005, 05:15 PM
#8
Thread Starter
Frenzied Member
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.
-
Jun 14th, 2005, 05:59 PM
#9
Re: Find a certian link
give me the site and ill show you an example
-
Jun 14th, 2005, 06:20 PM
#10
Thread Starter
Frenzied Member
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.
-
Jun 14th, 2005, 06:20 PM
#11
Re: Find a certian link
 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
-
Jun 14th, 2005, 06:36 PM
#12
Thread Starter
Frenzied Member
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?
-
Jun 14th, 2005, 06:40 PM
#13
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
-
Jun 14th, 2005, 06:49 PM
#14
Thread Starter
Frenzied Member
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?
-
Jun 14th, 2005, 06:59 PM
#15
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
-
Jun 14th, 2005, 07:08 PM
#16
Thread Starter
Frenzied Member
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.
-
Jun 14th, 2005, 11:02 PM
#17
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
-
Jun 15th, 2005, 09:10 AM
#18
Thread Starter
Frenzied Member
Re: Find a certian link
So, how do I open it and split?
-
Jun 15th, 2005, 12:10 PM
#19
Re: Find a certian link
VB Code:
x = inet1.openurl("Neopetswebsite.com",icstring)
dim cat() as string
dim i as integer
cat() = split(x,Vbcrlf)'this splits on everynew line
For i = 0 to ubound(cat)
If instr(cat(i),"<area shape=rect coords=") then
textbox1.text = textbox1.text & cat(i)
end if
next i
this will get all the sites, say something when you get this far
-
Jun 17th, 2005, 04:04 PM
#20
Thread Starter
Frenzied Member
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 ><
-
Jun 17th, 2005, 04:19 PM
#21
Re: Find a certian link
Project > Components > Microsoft Internet Transfer Control.
-
Jun 17th, 2005, 04:27 PM
#22
Thread Starter
Frenzied Member
Re: Find a certian link
Ok, so what do I do with that?
-
Jun 17th, 2005, 04:29 PM
#23
Re: Find a certian link
add it to your form, name it inet1, then follow my code.
-
Jun 17th, 2005, 04:35 PM
#24
Thread Starter
Frenzied Member
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.
-
Jun 17th, 2005, 05:32 PM
#25
Thread Starter
Frenzied Member
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?
-
Jun 17th, 2005, 10:27 PM
#26
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
-
Jun 17th, 2005, 10:37 PM
#27
Re: Find a certian link
This will tell you the site, along with the button caption.
VB Code:
Option Explicit
Dim cat() As String
Dim i As Integer
Dim x As String
Private Sub Form_Load()
x = Inet1.OpenURL("http://www.neopets.com/market.phtml", icString)
cat() = Split(x, Chr(10)) 'this splits on everynew line
For i = 0 To UBound(cat)
If InStr(cat(i), "<area shape=rect coords=") Then
Text1.Text = Text1.Text & cat(i)
End If
Next i
i = 0
Do Until InStr(Text1.Text, i) = 0
Text1.Text = Replace(Text1.Text, i, vbNullString)
i = i + 1
Loop
Text1.Text = Replace(Text1.Text, "<area shape=rect coords=", vbNullString)
Text1.Text = Replace(Text1.Text, "onmouseover=" & Chr(34) & "sh()" & Chr(34), vbNullString)
Text1.Text = Replace(Text1.Text, """,,,""", vbNullString)
cat() = Split(Text1.Text, "href=/")
For i = 0 To UBound(cat)
MsgBox ("http://www.neopets.com/market" & cat(i))
Next i
End Sub
-
Jun 18th, 2005, 02:22 AM
#28
Thread Starter
Frenzied Member
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?
-
Jun 18th, 2005, 02:28 AM
#29
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
-
Jun 18th, 2005, 02:40 AM
#30
Thread Starter
Frenzied Member
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.
-
Jun 18th, 2005, 11:49 AM
#31
Re: Find a certian link
yes...except i cant help you with this anymore..
-
Jun 18th, 2005, 12:01 PM
#32
Thread Starter
Frenzied Member
Re: Find a certian link
Well, thanks for the help, does anyone else know how to do what I am saying?
-
Jun 18th, 2005, 04:10 PM
#33
Fanatic Member
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:
Set myIE = CreateObject("InternetExplorer.Application")
myIe.Navigate "login url goes here"
do while myIe.Busy
DoEvents
loop
' replace "form" with the correct name of the login form
' and uname/password with the correct field names
myIe.form.uname = "username goes here"
myIe.password = "password goes here"
myIe.form.t
Do While myIe.Busy
DoEvents
loop
' fill in search box - again, replace "form" and "search"
' with the correct values to perform the search
myIe.form.search = "search text goes here"
myIe.form.submit
Do While myIe.Busy
DoEVents
loop
' since, as you say, the link is always the same at this point,
' just navigate to the known url
myIe.Navigate "place the url here"
Do While myIe.Busy
DoEvents
Loop
You should now be at the page you are trying to find
-
Jun 18th, 2005, 08:56 PM
#34
Thread Starter
Frenzied Member
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.
-
Jun 19th, 2005, 10:32 AM
#35
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|