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 (you need an account to see links) or send cookies with the HTTPWebRequest.
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.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)
Dim response As Net.HttpWebResponse = DirectCast(request.GetResponse, Net.HttpWebResponse)
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("http://www.neopets.com/captcha_show.phtml?_x_pwned=776fae5dc9d6b34cc133e3 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??
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 (you need an account to see links) or send cookies with the HTTPWebRequest.
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 (you need an account to 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)
ok tyvm
hey let say i login through web browser and navigate to "http://www.neopets.com/objects.phtml?obj_type=18&type=shop"
i copy the first item link address example:
(you need an account to 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?
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 HttpWebRequest
Dim response As HttpWebResponse
request = CType(WebRequest.Create(URL), HttpWebRequest)
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-www-form-urlencoded"
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(), HttpWebResponse)
Dim RT As String = New StreamReader(response.GetResponseStream()).ReadToE nd()
LastResponse = RT
Return RT
End Function