By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Get the next page using VB

P: 6
Hi, frnds

I am trying to read webpages.
Now i hv succeeded in reading the contents of web pages without tags but still the prblm is tht there are many pages to read.
So i read the 1st page , but i wanna read 2nd page or any no i specify in textbox.

example i read the "naukri.com" pages.
i read 1st page content,now i wanna turn to 2nd page from VB(without accessing to naukri.com page directly thru IE)

nilesh
May 1 '07 #1
Share this Question
Share on Google+
3 Replies


Robbie
100+
P: 180
Hi, frnds

I am trying to read webpages.
Now i hv succeeded in reading the contents of web pages without tags but still the prblm is tht there are many pages to read.
So i read the 1st page , but i wanna read 2nd page or any no i specify in textbox.

example i read the "naukri.com" pages.
i read 1st page content,now i wanna turn to 2nd page from VB(without accessing to naukri.com page directly thru IE)

nilesh
I think I am making something similar to what you want to make. I'm making something which downloads a page and then finds out where links to specific pages are on it, based on stuff which surrounds the links, which won't change unless the website changes their layout style.
I can make a function to find the "Next page" and "Previous page" links, but I need to have the exact web page. Is "naukri.com" just an example or is that the actual page? Because I see no Next Page or Previous Page links on naukri.com...
May 1 '07 #2

P: 6
I think I am making something similar to what you want to make. I'm making something which downloads a page and then finds out where links to specific pages are on it, based on stuff which surrounds the links, which won't change unless the website changes their layout style.
I can make a function to find the "Next page" and "Previous page" links, but I need to have the exact web page. Is "naukri.com" just an example or is that the actual page? Because I see no Next Page or Previous Page links on naukri.com...




just example
May 1 '07 #3

Robbie
100+
P: 180
just example
Okay. ^^;
But for example, on a page like this:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Page 2</title></head>
  3. <body>
  4. <h1>Heading</h1>
  5. <a href="page1.html">Prev. page</a><br>
  6. <a href="page3.html">Next page</a><br>
  7. The end
  8. </body>
  9. </html>
  10.  
The link to the next page in the HTML code above is "page3.html".

Here's a function I made which can find what the link of an "a href" tag in HTML is leading to, if you give it the text for that link. For example,
still using the example HTML code above. Text1.Text contains the HTML code and Text2.Text is empty at the moment.
We type this in VB:
Expand|Select|Wrap|Line Numbers
  1. Text2.Text = FindHrefLink(Text1.Text, "Next page")
Now Text2.Text is "page3.html".

Here is the function, it might be useful for you:
Expand|Select|Wrap|Line Numbers
  1. Public Function FindHrefLink(PageHTMLCode, LinkText)
  2.  
  3.     Dim TempPos As Variant  'Variant because web pages can
  4.                             'differ massively in size
  5.     Dim LeftOverCode As String
  6.  
  7.     LeftOverCode = PageHTMLCode
  8.     TempPos = InStrRev(LeftOverCode, Chr(34) + ">" + LinkText + "</a>")
  9. If TempPos=0 then
  10.     FindHrefLink = "Link not found"
  11. end if
  12.     LeftOverCode = Mid(LeftOverCode, 1, TempPos - 1)
  13.     TempPos = InStrRev(LeftOverCode, "href=" + Chr(34)) + 6
  14. If TempPos=6 then
  15.     FindHrefLink = "Href format error"
  16. end if
  17.     LeftOverCode = Mid(LeftOverCode, TempPos, Len(LeftOverCode) - (TempPos - 1))
  18.  
  19.     FindHrefLink = LeftOverCode
  20.  
  21. End Function
  22.  
If it can't find the link at all, it gives back "Link not found".
If it thinks it finds the link (the end of it, because it searches backwards), but it can't find the begining of the link (the "<a href=") then it gives back "Href format error".
I haven't tested it with real pages but it probably will work. You could probably try it out. ;)
May 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.