Go Back   Random Stuff Forums > Technical > Programming

Programming Discuss any type of programming here.

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-08-2009, 11:28 PM
Blupig's Avatar
Blupig (Offline)
wat i don't even
 
Join Date: Aug 2007
Posts: 157
Blupig is an unknown quantity at this point
Default [VB.net][TUT] Grabbing a page's source code

1. Start a new project (doesn't matter what it is as long as it has either a startup form or a sub main())

2. Import the System.Net library:
Imports System.Net
^That code goes above all of your other code

3. Initialize a new webclient (this can be global or for a single sub/function, it doesn't matter)

4. Declare a string to store the source code in

5. Using any event you like (clicking a button, pushing a key, etc.), call on the DownloadString class of the webclient:
strString = wcWebClient.DownloadString("http://www.website.com/")
strString is the name of your string you declared earlier, wcWebClient is the name of the webclient you created.

You're now done.

Example code:

Imports System.Net
Public Class Form1

    Dim wcWebClient As New Webclient
    Dim strString As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

               strString = wcWebClient.DownloadString("http://www.google.ca/")

    End Sub
End Class
How is this useful at all? Well with the source from a webpage you can parse information. This is what Runescape clients use for example to parse through online databases.

Last edited by Blupig; 11-08-2009 at 11:29 PM..
Reply With Quote
  #2  
Old 12-08-2009, 03:33 AM
Chase's Avatar
(Offline)
RSF Regular
 
Join Date: Mar 2007
Location: Australia
Posts: 2,284
Chase is an unknown quantity at this point
Default

Can't you just right click "View Source Code" or something?
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Reply With Quote
  #3  
Old 12-08-2009, 05:42 PM
Blupig's Avatar
Blupig (Offline)
wat i don't even
 
Join Date: Aug 2007
Posts: 157
Blupig is an unknown quantity at this point
Default

Originally Posted by Chase View Post
Can't you just right click "View Source Code" or something?
No, that's only in browsers. This is for grabbing page code without opening a browser at all.
Reply With Quote
  #4  
Old 13-08-2009, 07:06 PM
Epiic's Avatar
Epiic (Offline)
Member
 
Join Date: Dec 2008
Location: Illinois, US
Posts: 224
Epiic is an unknown quantity at this point
Default

I get an error in Systems.dll when I try this.
__________________
"A working class hero is something to be."
Reply With Quote
  #5  
Old 19-08-2009, 12:03 PM
Blupig's Avatar
Blupig (Offline)
wat i don't even
 
Join Date: Aug 2007
Posts: 157
Blupig is an unknown quantity at this point
Default

Originally Posted by Epiic View Post
I get an error in Systems.dll when I try this.
A direct copy pasta would help.
__________________
Spark a match and light the flame, come sit down and play a game. Before you sit, you should know, you've lost the game, you dirty ho.
Reply With Quote
  #6  
Old 19-08-2009, 07:36 PM
Epiic's Avatar
Epiic (Offline)
Member
 
Join Date: Dec 2008
Location: Illinois, US
Posts: 224
Epiic is an unknown quantity at this point
Default

Originally Posted by Blupig View Post
A direct copy pasta would help.
orly.. i did it and it didnt work.
__________________
"A working class hero is something to be."
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:06 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright © 2006 - 2010, Rsforums.org