PDA

View Full Version : [vb.net] main shop catcha image to picturebox HELP!



stacyK
05-20-2012, 01:13 AM
Hi, i faced some errors while trying to retrieve the image from the haggle page..

Public Sub LoadImageFromUrl(ByRef url As String, ByVal pb As PictureBox)
Dim request As Net.[Only registered and activated users can see links] = DirectCast(Net.[Only registered and activated users can see links](url), Net.[Only registered and activated users can see links])
Dim response As Net.[Only registered and activated users can see links] = DirectCast(request.GetResponse, Net.[Only registered and activated users can see links])
Dim img As Image = Image.FromStream(response.GetResponseStream())
response.Close()
pb.SizeMode = PictureBoxSizeMode.StretchImage
pb.Image = img
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

LoadImageFromUrl("[Only registered and activated users can see links] 759e49e573.jpg", PictureBox1)

End Sub


im statically retrieving image from the haggle page but it gave me the error "Parameter is not valid".

Error line:
Dim img As Image = Image.FromStream(response.GetResponseStream())


anyone can help?? :$


i thought of another way.. which is storing all types of captcha image..then naming the file as the pet name.
Comparing the filename (kau.jpg) with the pet example: kau

"Enter the amount you wish to pay, <br>then click on the <strong>Kau</strong> to continue.<br>"

and proceed with haggling.. will this work??

Zachafer
05-20-2012, 03:35 AM
The problem is simple. When you load the captcha image, the cookies are not sent and so Neo will send you headers that say redirect to login.phtml

You need to either use a wrapper ([Only registered and activated users can see links]) or send cookies with the [Only registered and activated users can see links]

stacyK
05-20-2012, 11:49 AM
The problem is simple. When you load the captcha image, the cookies are not sent and so Neo will send you headers that say redirect to login.phtml

You need to either use a wrapper ([Only registered and activated users can see links]) or send cookies with the [Only registered and activated users can see links]

hey sorry im new to programming.. how do you call the wrapper or import the wrapper dll in visual studio vb.net??

stacyK
05-20-2012, 12:03 PM
hey isit because i manually login to through web browser and copied the url of the image into the program which causes the problem? is the browser and program using different connection?

should i use login from my program and use function like get or post data to retrieve the url of the image?

Zachafer
05-20-2012, 01:06 PM
hey isit because i manually login to through web browser and copied the url of the image into the program which causes the problem? is the browser and program using different connection?

should i use login from my program and use function like get or post data to retrieve the url of the image?
Your main problem is going to come from Image.FromStream. Just because the Image class has a .FromStream() method doesn't mean that any stream is a valid image, and the html response from a web server certainly would not be a valid image.
Try this: clear your cookies in your web browser then visit [Only registered and activated users can see links]

You will be redirected to the login page. The login page is a bunch of HTML, not an image. That is why your code is failing. It is trying to visit captcha_show.phtml and download the results as an image, but since it is not logged in, it tries to convert HTML/text to an image.

I would check into using the cxWrapper.dll that I linked to you in my previous post. I will show you how to use it (with code) later.

stacyK
05-20-2012, 08:36 PM
ok tyvm :$

stacyK
05-20-2012, 09:12 PM
Your main problem is going to come from Image.FromStream. Just because the Image class has a .FromStream() method doesn't mean that any stream is a valid image, and the html response from a web server certainly would not be a valid image.
Try this: clear your cookies in your web browser then visit [Only registered and activated users can see links]

You will be redirected to the login page. The login page is a bunch of HTML, not an image. That is why your code is failing. It is trying to visit captcha_show.phtml and download the results as an image, but since it is not logged in, it tries to convert HTML/text to an image.

I would check into using the cxWrapper.dll that I linked to you in my previous post. I will show you how to use it (with code) later.


hey i got it working.. thanks for the help! ;)

stacyK
05-21-2012, 01:02 AM
hey let say i login through web browser and navigate to "[Only registered and activated users can see links]"

i copy the first item link address example:
[Only registered and activated users can see links]

i paste it on my url bar and enter it says

Error: You have been directed to this page from the wrong place! If you KEEP getting this error, chances are you have some security settings enabled that are not letting you play Neopets correctly.

is it because of the message box that appear when i clicked on the item? how do i post the data?

Zachafer
05-21-2012, 04:25 PM
hey let say i login through web browser and navigate to "[Only registered and activated users can see links]"

i copy the first item link address example:
[Only registered and activated users can see links]

i paste it on my url bar and enter it says

Error: You have been directed to this page from the wrong place! If you KEEP getting this error, chances are you have some security settings enabled that are not letting you play Neopets correctly.

is it because of the message box that appear when i clicked on the item? how do i post the data?
Are you trying to post the data using your browser? or using VB.net?

I very strongly urge you to use a wrapper - and cxWrapper is one of the best.

stacyK
05-21-2012, 09:52 PM
Are you trying to post the data using your browser? or using VB.net?

I very strongly urge you to use a wrapper - and cxWrapper is one of the best.

i'm trying to go through the motion from the web browser before i code it.. but seems like it doesnt work.

isit because of the confirmation box after clicking the item?

example:
Are you sure you wish to purchase Large Spirulina Smoothie at 585 NP?
(you can still haggle to push the price lower!)

do i have to return true?


this is what im using for post data.
Public Function PostData(ByRef URL As String, ByRef POST As String, Optional ByVal Referer As String = "") As String
Dim request As [Only registered and activated users can see links]
Dim response As [Only registered and activated users can see links]
request = CType(WebRequest.Create(URL), [Only registered and activated users can see links])
If UseCookies = True Then request.CookieContainer = Me.NeoCookies
If UseProxy Then
request.Proxy = New System.Net.WebProxy(ProxyIp & ":" & ProxyPort)
End If
request.ContentType = "application/x-[Only registered and activated users can see links]"
request.UserAgent = UserAgent
request.ContentLength = POST.Length
request.Referer = Referer
request.Method = "POST"
request.AllowAutoRedirect = True
Dim requestStream As Stream = request.GetRequestStream()
Dim postBytes As Byte() = Encoding.ASCII.GetBytes(POST)
requestStream.Write(postBytes, 0, postBytes.Length)
requestStream.Close()
response = CType(request.GetResponse(), [Only registered and activated users can see links])
Dim RT As String = New StreamReader(response.GetResponseStream()).ReadToE nd()
LastResponse = RT
Return RT
End Function

Zachafer
05-22-2012, 12:57 AM
i'm trying to go through the motion from the web browser before i code it.. but seems like it doesnt work.

isit because of the confirmation box after clicking the item?

example:
Are you sure you wish to purchase Large Spirulina Smoothie at 585 NP?
(you can still haggle to push the price lower!)

do i have to return true?


this is what im using for post data.
Public Function PostData(ByRef URL As String, ByRef POST As String, Optional ByVal Referer As String = "") As String
Dim request As [Only registered and activated users can see links]
Dim response As [Only registered and activated users can see links]
request = CType(WebRequest.Create(URL), [Only registered and activated users can see links])
If UseCookies = True Then request.CookieContainer = Me.NeoCookies
If UseProxy Then
request.Proxy = New System.Net.WebProxy(ProxyIp & ":" & ProxyPort)
End If
request.ContentType = "application/x-[Only registered and activated users can see links]"
request.UserAgent = UserAgent
request.ContentLength = POST.Length
request.Referer = Referer
request.Method = "POST"
request.AllowAutoRedirect = True
Dim requestStream As Stream = request.GetRequestStream()
Dim postBytes As Byte() = Encoding.ASCII.GetBytes(POST)
requestStream.Write(postBytes, 0, postBytes.Length)
requestStream.Close()
response = CType(request.GetResponse(), [Only registered and activated users can see links])
Dim RT As String = New StreamReader(response.GetResponseStream()).ReadToE nd()
LastResponse = RT
Return RT
End Function

Another hint for you: Download Live[Only registered and activated users can see links] for Firefox. ([Only registered and activated users can see links]) It will allow you to see the page requests your browser is making (ie POST vs GET, what data is being sent, etc)

stacyK
05-22-2012, 01:07 AM
Another hint for you: Download Live[Only registered and activated users can see links] for Firefox. ([Only registered and activated users can see links]) It will allow you to see the page requests your browser is making (ie POST vs GET, what data is being sent, etc)

i downloaded this yesterday haha

Zachafer
05-22-2012, 01:08 AM
Then check the headers being sent when you click "Ok" on the confirm popup box

stacyK
05-22-2012, 02:00 AM
Then check the headers being sent when you click "Ok" on the confirm popup box

hhmm its a get request [Only registered and activated users can see links] tried it before, didnt work.. thanks anyway :$

Zachafer
05-23-2012, 08:38 AM
hhmm its a get request [Only registered and activated users can see links] tried it before, didnt work.. thanks anyway :$

Look at the Referrer header value