Results 1 to 13 of 13

Thread: GetPage in Visual Basic 2008?

  1. #1
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default GetPage in Visual Basic 2008?

    So is there a function like that in vb?
    If no then how can I place a webpage's source code into a string?

    Also as I am learning the language it would be cool to have someone on msn who can and would like to help. Be ready that I may ask totally dumb questions tho.

    Oh, and I don't know if it's important or not but now I am just writing console applications and my teacher doesn't want me to use object oriented features first.

    Thanks in advance!

  2. #2
    Join Date
    Sep 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I would use System.Net.WebClient.

    Code:
    // in C#
    System.Net.WebClient wc = new System.Net.WebClient();
    System.IO.StreamReader reader = wc.OpenRead("http://www.google.fi");
    System.Console.WriteLine(reader.ReadToEnd());

  3. #3
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    Private Sub Command1_Click()
     Open App.Path & "\test.html" For Input As #1
     Do While Not EOF(1) ' Loop until end of file.
       Input #1, mystring ' Read data into two variables.
        Text1.Text = Text1.Text & mystring & vbCrLf
    Loop
    Close #1
    End Sub
    If you want to read HTML without using the browser control then use this..
    Code:
    Dim objLink As HTMLLinkElement
    Dim objMSHTML As New MSHTML.HTMLDocument
    Dim objDocument As MSHTML.HTMLDocument
    
    
    ' This function is only available with Internet Explorer 5
    
    Set objDocument = objMSHTML.createDocumentFromUrl(txtURL.Text, _
                                                      vbNullString)
    
    ' Tricky, to make the function wait for the document to
    ' complete, usually the transfer is asynchronous. Note
    ' that this string might be different if you have another
    ' language than English for Internet Explorer on the
    ' machine where the code is executed.
    
    While objDocument.readyState <> "complete"
        DoEvents
    Wend
    
    ' Source Code
    
    Debug.Print = objDocument.documentElement.outerHTML
    
    ' Title
    
    Debug.Print "Title : " & objDocument.Title
    
    ' Link Collection
    
    For Each objLink In objDocument.links
        lstLinks.AddItem objLink
        Debug.Print "Link:  " & objLink
    Next
    http://www.codeguru.com/vb/vb_intern...cle.php/c4815/

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  4. #4
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Actually it's php.
    For example: http://www.heroesofnewerth.com/heroview.php?hid=15
    Sorry that I forgot to mention this.
    Currently I am trying what fronty said and I already learned a few new thing. I will report back how it goes.

  5. #5
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Doesnt matter you wont be able to read PHP.

    Everything on that page is in HTML.

    If you tell us excatly what your trying to do then that may help instead of us posting help which is irrelevant.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  6. #6
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I just wanted to get the source of the webpage to a string. Just like GetPage works in scar.
    But basicly I want this:
    SCAR Code:
    program New;

    procedure FillUp;

    var
      S, HeroName, StatName, Stat: string;
      SA, SAI: TStringArray;
      H, i, o, p: Integer;

    begin
      SAI := ['<li class="cat" style="width: 170px;">Movement Speed</li>', +
      '<li class="cat" style="width: 170px;">Str per Level</li>', +
      '<li class="cat" style="width: 170px;">Agi per Level</li>', +
      '<li class="cat" style="width: 170px;">Int per Level</li>', +
      '<li class="cat" style="width: 170px;">Armor</li>', +
      '<li class="cat" style="width: 170px;">Dmg. Reduction</li>', +
      '<li class="cat" style="width: 170px;">Magic Armor</li>', +
      '<li class="cat" style="width: 170px;">Magic Dmg. Reduction</li>'];
      for p := 0 to 116 do
      begin
        S := GetPage('http://www.heroesofnewerth.com/heroview.php?hid=' + IntToStr(p) + '');
        HeroName := Between('Hero Name</b></span><br>', '<br>', S);
        if HeroName = '' then Continue;
        WriteLn(HeroName + ':' + #13);
        SA := Explode(#10, S);
        H := High(SA);
        for o := 0 to 7 do
        begin
          for i := 0 to H do
          begin
            if Pos(SAI[o], SA[i]) > 0 then
            begin
              StatName := Between('>', '<', SAI[O]);
              Stat := Between('>', '<', SA[i + 2]);
              WriteLn(StatName + ': ' + Stat);
              WriteINI(HeroName, StatName, Stat, ScriptPath + 'HeroDatabase.ini');
              Break;
            end;
          end;
        end;
        WriteLn(#13);
      end;
    end;


    var
      f: Integer;

    begin
      FillUp;
    end.
    in VB.

    But I don't want you just to give me a full working program because I won't learn from that too much.

    EDIT: I got it now with fronty's method. Although it's not in a string, yet.
    Last edited by Sabzi; 11-28-2009 at 06:10 PM.

  7. #7
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default


    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  8. #8
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Oh! I was about to write Between but now I don't have to. Thank you! Can't rep you twice

  9. #9
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sabzi View Post
    Oh! I was about to write Between but now I don't have to. Thank you! Can't rep you twice
    No problemo.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  10. #10
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't want to start a new thread so I ask here.
    Everything except the WriteINI line is okay(thx to you all).
    I have found something about that in the "library" but it was so long mentioning registry and I don't know what that I felt like I don't want it.
    Is there any easier way of doing that?

    tl;dr:
    SCAR Code:
    WriteINI(HeroName, StatName, Stat, ScriptPath + 'HeroDatabase.ini');
    ^this in Visual Basic?(from the script a few post above)

    Thx again!

  11. #11
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default


    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  12. #12
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    <3!
    I gotta check that forum next time before I ask :S

  13. #13
    Join Date
    Nov 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    make use of the .NET BCL. System.Web :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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