Quantcast

Jump to content


Photo

[VB.net] How to grab the Neopets Main shop captcha


  • Please log in to reply
7 replies to this topic

#1 Backslash

Backslash
  • 47 posts

Posted 24 October 2009 - 08:10 AM

Can you help me figure out how to do this? Grab the image and then put it in a picturebox. It doesnt let me do it, i used this function:

Public Function GetImage(ByVal ImageURL As String, ByVal pb As PictureBox) As Boolean

 	Dim objImage As MemoryStream
 	Dim objwebClient As WebClient
 	Dim sURL As String = Trim(ImageURL)
 	Dim bAns As Boolean

 	Try
 	If Not sURL.ToLower().StartsWith("http://") _
 	Then sURL = "http://" & sURL
 	objwebClient = New WebClient()


 	objImage = New _
 	MemoryStream(objwebClient.DownloadData(sURL))
 	pb.Image = Image.FromStream(objImage)
 	bAns = True
 	Catch ex As Exception

 	bAns = False
 	End Try

 	Return bAns

	End Function


#2 ((_Blade_))

((_Blade_))
  • 20 posts

Posted 24 October 2009 - 09:36 AM

Just tried it...it works fine. Whats the error you're getting?

'Example Usage
        GetImage("http://images.neopets.com/items/mall_aotaticket_challenge.gif", PictureBox1)


#3 Backslash

Backslash
  • 47 posts

Posted 24 October 2009 - 09:39 AM

Yes it works, but not for:
http://www.neopets.c...tcha_show.phtml
which is the image for the captcha. :(

Not sure what the problem is, i think it has something to do with the headers, making it corrupted image.

#4 ((_Blade_))

((_Blade_))
  • 20 posts

Posted 24 October 2009 - 10:14 AM

Yes it works, but not for:
http://www.neopets.c...tcha_show.phtml
which is the image for the captcha. :(

Not sure what the problem is, i think it has something to do with the headers, making it corrupted image.


You need to be logged in in-order to view that image

Just tried

Dim html As String = objwebClient.DownloadString("http://www.neopets.com/captcha_show.phtml")

which returned

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
 host - neopets-web-87.811.mtvi.com
//-->
<html>
<head>
	<meta name="description" content="Neopets.Com - Virtual Pet Community! Join up for free games, shops, auctions, chat and more!">
....
	
<a href="/loginpage.phtml"><b>Login to Neopets!</b></a>				</td>

....

Try using the net.sockets class to send the cookies + retrieve data. There should be a few .Net HTTPWrappers floating around that already do this for you (Google's your friend ;) )

Edited by ((_Blade_)), 24 October 2009 - 10:15 AM.


#5 Backslash

Backslash
  • 47 posts

Posted 24 October 2009 - 10:24 AM

Thanks for the help! I tried googling, but all I got was the wrapper I have. I will look some more.

#6 ((_Blade_))

((_Blade_))
  • 20 posts

Posted 24 October 2009 - 10:39 AM

Thanks for the help! I tried googling, but all I got was the wrapper I have. I will look some more.

http://lmgtfy.com/?q=httpwrapper+vb.net
(Always wanted to try that xD )

Check the first link. It looks complete (never tried it so I don't know if it has bugs in it)

Once you've logged in + retrived the source, make sure you strip the headers from it (if there is any...you usually never have to do this)...

Dim i As Integer = html.IndexOf("\r\n\r\n") + 4
        html = html.Substring(i, html.Length - i)

then set the picturebox to the image

pb.Image = Image.FromStream(New MemoryStream(Encoding.Default.GetBytes(html)))

Otherwise you're going to get "invaild paramater" errors ;)

Edit...added references you might need
Imports System.IO
Imports System.Net
Imports System.Text

Edited by ((_Blade_)), 24 October 2009 - 11:11 AM.


#7 Backslash

Backslash
  • 47 posts

Posted 24 October 2009 - 11:28 AM

Okay i edited my whole form with the new wrapper, and now it doesnt log in, its giving me an error, but with the other wrapper it works fine :(

Edit: I found a variation of the TCPWrapper and currently trying..

Great... It didnt work. It has a Grabpic function that atuomatically strips the headers, but my form freezes. This is gonna take ages ;-;

Edited by Backslash, 24 October 2009 - 11:21 AM.


#8 ((_Blade_))

((_Blade_))
  • 20 posts

Posted 24 October 2009 - 05:26 PM

Okay i edited my whole form with the new wrapper, and now it doesnt log in, its giving me an error, but with the other wrapper it works fine :(

Edit: I found a variation of the TCPWrapper and currently trying..

Great... It didnt work. It has a Grabpic function that automatically strips the headers, but my form freezes. This is gonna take ages ;-;


Does the form freeze temporarily while downloading the source or indefinitely?

If its the temporary...then everything's GOOD. The wrapper's just preoccupied for a bit so the forms not being repainted.
Look up tutorials on multithreading for .Net and run the wrapper on a different thread to keep the gui responsive.


(I'm searching my backups for my old AB written in C#. Once I find it, its source code will probably be uploaded publicly so people can learn from it :) )

Edited by ((_Blade_)), 24 October 2009 - 05:37 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users