Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: [vb.net] main shop catcha image to picturebox HELP!

  1. #1
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A

    [vb.net] main shop catcha image to picturebox HELP!

    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??

  2. #2
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    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.

  3. #3
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Zachafer View Post
    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 sorry im new to programming.. how do you call the wrapper or import the wrapper dll in visual studio vb.net??

  4. #4
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    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?

  5. #5
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Quote Originally Posted by stacyK View Post
    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.

  6. The Following User Says Thank You to Zachafer For This Useful Post:

    stacyK (05-20-2012)

  7. #6
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    ok tyvm

  8. #7
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Zachafer View Post
    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.

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

  9. #8
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    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?

  10. #9
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Quote Originally Posted by stacyK View Post
    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?
    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.

  11. #10
    stacyK's Avatar
    Joined
    May 2012
    Posts
    13
    Userbars
    0
    Thanks
    4
    Thanked
    0/0
    Mentioned
    Never
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Zachafer View Post
    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 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •