Get the next page using VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilya
    New Member
    • Apr 2007
    • 6

    Get the next page using VB

    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
  • Robbie
    New Member
    • Mar 2007
    • 180

    #2
    Originally posted by Nilya
    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...

    Comment

    • Nilya
      New Member
      • Apr 2007
      • 6

      #3
      Originally posted by Robbie
      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

      Comment

      • Robbie
        New Member
        • Mar 2007
        • 180

        #4
        Originally posted by Nilya
        just example
        Okay. ^^;
        But for example, on a page like this:
        Code:
        <html>
        <head><title>Page 2</title></head>
        <body>
        <h1>Heading</h1>
        <a href="page1.html">Prev. page</a><br>
        <a href="page3.html">Next page</a><br>
        The end
        </body>
        </html>
        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:
        Code:
        Text2.Text = FindHrefLink(Text1.Text, "Next page")
        Now Text2.Text is "page3.html ".

        Here is the function, it might be useful for you:
        Code:
        Public Function FindHrefLink(PageHTMLCode, LinkText)
            
            Dim TempPos As Variant  'Variant because web pages can
                                    'differ massively in size
            Dim LeftOverCode As String
            
            LeftOverCode = PageHTMLCode
            TempPos = InStrRev(LeftOverCode, Chr(34) + ">" + LinkText + "</a>")
        If TempPos=0 then
            FindHrefLink = "Link not found"
        end if
            LeftOverCode = Mid(LeftOverCode, 1, TempPos - 1)
            TempPos = InStrRev(LeftOverCode, "href=" + Chr(34)) + 6
        If TempPos=6 then
            FindHrefLink = "Href format error"
        end if
            LeftOverCode = Mid(LeftOverCode, TempPos, Len(LeftOverCode) - (TempPos - 1))
            
            FindHrefLink = LeftOverCode
            
        End Function
        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. ;)

        Comment

        Working...