Results 1 to 11 of 11
  1. #1
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow

    [TUT] Reading lines from a web document.

    Well this isn't so much a tut as a quick snippet. It's a pretty handy function. I'll do my best to explain what it does within the code by annotating.

    I'm not sure if this is the most effective way of doing it but yeah, I just figured this out myself 'cos nothing was really working. Pretty simple to follow but very useful. I used this extensively in my MPGH.net download and multi-tool (both got closed 'cos they were too epic)

    anywho,

    here's the function

    [php]
    Function ReadLiner(ByVal Pageurl As String)

    Dim Lines As String = ""
    Try
    Dim request As HttpWebRequest = WebRequest.Create(Pageurl)
    Dim response As HttpWebResponse = request.GetResponse()
    Using reader As StreamReader = New StreamReader(response.GetResponseStream())

    Lines = reader.ReadLine 'reads the current line'

    Do While (Not Lines Is Nothing) 'will do the following for every line until it encounters an empty line, do whatever you want here'

    'do something here, ill put an example underneath'

    Console.WriteLine(Lines)

    Lines = reader.ReadLine

    Loop

    End Using

    Catch ex As Exception

    'if the URL isnt found, what will you do?'

    End Try

    Return Lines

    End Function
    [/php]

    Then to use:

    [php]

    ReadLiner("https://example.com/test.txt") ' your URL goes there'

    [/php]


    examples of use:

    1. Add each line to a listbox.

    [php]
    Function ReadLiner(ByVal Pageurl As String)

    Dim Lines As String = ""
    Try
    Dim request As HttpWebRequest = WebRequest.Create(Pageurl)
    Dim response As HttpWebResponse = request.GetResponse()
    Using reader As StreamReader = New StreamReader(response.GetResponseStream())

    Lines = reader.ReadLine 'reads the current line'

    Do While (Not Lines Is Nothing)

    Listbox1.Items.Add(Lines)

    Console.WriteLine(Lines)

    Lines = reader.ReadLine

    Loop

    End Using

    Catch ex As Exception



    End Try

    Return Lines

    End Function
    [/php]


    2. Incorporating cases (only realistic with a few cases, I used something similar in my downloader with 4 cases -.-)

    [php]
    Function ReadLiner(ByVal Pageurl As String)

    Dim i as Integer = 0

    Dim Lines As String = ""
    Try
    Dim request As HttpWebRequest = WebRequest.Create(Pageurl)
    Dim response As HttpWebResponse = request.GetResponse()
    Using reader As StreamReader = New StreamReader(response.GetResponseStream())

    Lines = reader.ReadLine 'reads the current line'

    Do While (Not Lines Is Nothing)
    i += 1 '(this adds 1 to the integer 'i' every new line)'
    Select Case(i)
    Case1
    'Do what you want for the first line for example'
    Label1.Text = Line

    Case2
    'what do you want to do with the 2nd line..'

    'etc etc etc, add more cases as the need arises'

    End Select

    Console.WriteLine(Lines)

    Lines = reader.ReadLine

    Loop

    End Using

    Catch ex As Exception

    'if the URL isnt found, what will you do?'

    End Try

    Return Lines

    End Function
    [/php]

    And yeah that's about it for reading each line of a document. Hope someone gets something out of this.

    J-Deezy

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  2. The Following 3 Users Say Thank You to Jason For This Useful Post:

    /b/oss (06-07-2010),Julma Henri (06-08-2010),Lolland (06-08-2010)

  3. #2
    Julma Henri's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    3,528
    Reputation
    205
    Thanks
    775
    My Mood
    In Love
    Nice tut J-Deezy
    Help me get donator.



    Want to become part of Editor Force? Click the tag below and apply now !

  4. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Nice tutorial !! Thanks for sharing..

  5. #4
    /b/oss's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    13,651
    Reputation
    795
    Thanks
    3,547
    j-dezzy awesomnness aggaiN!

  6. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by m_t_h View Post
    j-dezzy awesomnness aggaiN!
    J-Deezy ** but thanks.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  7. #6
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by J-Deezy View Post
    J-Deezy ** but thanks.
    NOT A SPAMMER!!! YAY!! finally, nice one J-Deezy.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  8. #7
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Brinuz View Post
    NOT A SPAMMER!!! YAY!! finally, nice one J-Deezy.
    Hahaha maybe I should incorporate it into a spammer. I'm watching NCIS right now so im aircoding right here

    No C&P, I don't have VB on this computer, wonder how many syntax errors i get

    You ned (for this fictional piece of shit)

    TextBox1 is the delay
    Button1 is to fill the listbox from the website specified in TextBox2
    TextBox2 is the webpage to read from
    Button2 is to start spam
    Button3 is to stop spam
    lblStatus states the status (spamming/idle)

    FUCK YEAH!

    [php]
    Imports System.NET
    Imports System.IO

    Public Class Form1

    Private Function Reade(ByVal pages As String)

    dim lines as string = ""

    Try
    Dim request As HttpWebRequest = WebRequest.Create(Pages)
    Dim response As HttpWebResponse = request.GetResponse()
    Using reader As StreamReader = New StreamReader(response.GetResponseStream())

    lines = reader.readline

    Do while (not lines is nothing)

    ListBox1.Items.Add(lines)
    Console.WriteLine(lines)
    lines = reader.readline

    Loop


    End Using
    Catch ex As Exception

    End Try

    Return lines
    End Function

    Private Sub Button1_click(ByVal...yeah shit goes here im not that good) Handles Button1.click

    'summary: This button fills the listbox with the text'
    If not TextBox2.Text = "" then
    try
    reade(TextBox2.Text)
    catch ex as Exception
    End try

    Else: MsgBox("Please enter a website to load from", vbinformation, "No website specified")


    End Sub

    Private Sub randomline()
    'this generates a random listbox entry'
    dim randoms as new random
    dim x as integer = ListBox1.Items.Count
    dim i as integer = randoms.next(0, x)

    ListBox1.SelectedIndex = i

    End Sub

    Private sub Timer1_tick(ByVal....) Handles Timer1.Tick
    'spams a random listbox entry'
    call randomline()
    SendKeys.Send(Listbox1.SelectedItem)
    SendKeys.Send("{ENTER}")

    End Sub

    Private Sub Button2_click(ByVal....) Handles Button2.Click
    'the start spam button'
    if not textbox1.text = "" then
    Timer1.Interval = Textbox1.Text 'oh yeah customizable delay ^^'
    Else: Timer1.Interval = 200
    End If

    Timer1.Start()
    lblStatus = "Spamming"
    lblStatus.ForeColor = Color.Lime

    End Sub

    Private Sub Button3_click(Byval....)Handles Button3.Click
    'the stop spam button'

    Timer1.Stop()
    lblStatus = "Idle"
    lblStatus.ForeColor = Color.Red

    End Sub

    End Class

    [/php]

    Air code over and out

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  9. #8
    Hawky1337's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    88
    Reputation
    11
    Thanks
    27
    My Mood
    Shocked
    Not hard, but very good job. A lot of people don't know how to do such.

    Tip: Instead of rewriting a long code everytime and changing just a bit, simply do one function (see above)

  10. #9
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Wow I'm a genius, my above code worked flawlessly.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  11. #10
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by J-Deezy View Post
    Wow I'm a genius, my above code worked flawlessly.
    Haha then you won't mind checking these xD :

    [Collection]Snippets Vault - Visual Basics - MPGH - MultiPlayer Game Hacking

    [Collection]Snippets Vault - Visual Basics - MPGH - MultiPlayer Game Hacking


  12. #11
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Shut up , I be but a humble choob next to the awesome might of your VB knowledge. Minion this douche now plocks.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

Similar Threads

  1. [Help] Getting "Class" attribute from a web browser document
    By willrulz188 in forum Visual Basic Programming
    Replies: 3
    Last Post: 10-21-2011, 12:22 PM
  2. [TUT]How to read input from keyboard
    By XORxHACK in forum Java
    Replies: 3
    Last Post: 05-07-2010, 05:03 PM
  3. Reading lines from text file?
    By ppl2pass in forum Visual Basic Programming
    Replies: 4
    Last Post: 02-23-2010, 09:27 AM
  4. Fixes for various Errors, Read!(straight from Nexon Forums)
    By mariokiller64 in forum Combat Arms Hacks & Cheats
    Replies: 9
    Last Post: 09-05-2008, 06:02 PM
  5. Replies: 11
    Last Post: 08-28-2007, 02:49 AM