"Parameter is not valid"

Discussion in 'Code Snippets and Tutorials' started by turato, Mar 31, 2009.

  1. turato

    turato Level III

    Joined:
    Aug 3, 2007
    Messages:
    408
    Likes Received:
    0
    This error is really starting to piss me off =(. I've created the most basic app to download a captcha from neopets then output it in a picturebox.
    I've gotten it to work for all images except for neopet captchas, it's puzzling me. Here is my code:

    Code (Text):
    1. Dim w As New RickysWrapper
    2. w.GetRequest("http://www.neopets.com/login.phtml?destination=%2Findex.phtml&username=" & textbox1.text & "&password=" & textbox2.text & "&x=53&y=12")
    3. Dim img As Bitmap = Image.FromStream(w.DownloadImage("http://www.neopets.com/captcha_show.phtml?_x_pwned=4875c3e7d97e026f58b8fa3d22cf4819"))
    Error is obviously on the third line. It logs in to view the captcha, then tries to get the captcha image, but for some silly reason it won't work.
    Help would be greatly appreciated, I've uploaded RickysWrapper to sendspace just incase you need it (neofriends.net won't let users upload any files with the extension .vb).

    Help would be greatly appreciated, I've tried searching google but nothing helped. I've been trying for days to figure it out, now I need your help.

    RICKYSWRAPPER LINK:
    Code (Text):
    1. http://www.sendspace.com/file/5t59a0
    PS:
    This error is preventing me to complete my Autobuyer which I've spent so much time on :|
     
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    There's no Grabpic function in your wrapper ???

    And did you validate the first line of your code (putting in a textbox to see if you're really logged in)???
    I'm pretty sure you need to go throught all the page (login, hi, index) to successfully login (again, I might be wrong... but the way you're doing it got me iced already...)

    And again, almost all post/get command need a referer/refCheck. That how TnT check if you're cheating or not...

    Anyway, just my 2c
     
  3. turato

    turato Level III

    Joined:
    Aug 3, 2007
    Messages:
    408
    Likes Received:
    0
    My wrapper has a grabpic function, it's called DownloadImage, but perhaps it's the function that's not working. I always fixed the login thing you were talking about, still doesn't work, and for sure I'm logged in.
    This is frustrating lol. Thanks for trying to help though, any more suggestions?

    BTW:
    I don't know if this could be part of the problem, but when I manually try to download the image from firefox, the default extension of the image captcha is .phtml.
     
  4. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    it's normal... the captcha itself is contained in a frame.

    example:
    When you click a link to buy something, you end up in the haggle. Then, they call another page (let's say captcha.phtml) witch only contains a jpg image. If you do view source on the captcha, you can retrieve the link of the img.
     
  5. turato

    turato Level III

    Joined:
    Aug 3, 2007
    Messages:
    408
    Likes Received:
    0
    Are you saying view the source of the captcha? Because when my program visited this link:
    http://www.neopets.com/captcha_show.pht ... 3d22cf4819

    It stored the source in the string. The string is this:
    Code (Text):
    1. ���� JFIF   d d  ï¿½ï¿½ Ducky       ï¿½ï¿½ Adobe d�   �� �   
    2. #%'%#//33//@@@@@@@@@@@@@@@&&0##0+.'''.+550055@@?@@@@@@@@@@@@��  � �" �� �                                 !1AQaq��"��2BR��#3��bC�4         !1AQaq"�2����r��   ? �h��I43:
    3. 9  %="��PV��^/E���[Ô·*3�* $��p(��"�����1*�*� P&s:3�dS�Y �UC
    4.  Q��$P���P^7{�W��74w����ٍ����c��o���1�S���Ս��e��F�6iYQ�u�E�-�x�<��g �Y�}#�?�c� �� Cl1�ψ�wWZ�GZ�h�2+^���%�=J�"u��u�"w5t�ju�L�ժ�w)ʴ��Ȫ��鼖G����y�K���K$���&�):I�:
    5. ���I����U+K�RSȦ@��X�:�9ʦ �Y(�n"1cjeo���&��t#��p��N�k�3�FiNő�"Ag�d�;���1�g��sarXXf����J�|���鋑G,>�Au�|���� �͐��c�V<C�?�Z�'����v��U\�*c�@���EyN�+']�
    6. �9+�9x�R�/�[��y_ ����)$nz�L�ɟ/t��x�N!���O�����q�v�J{�r>�����E�����bFS�uZ�SB���M(�Z��0�'7'�^�ڟ�p��v�pqî²»y�?AUS�}H��-D�u3ȃ��>��J�¥�^�ͧ��  ˶�ݒS���kJ����kUA���ȓӬ�-��#n �$�*�Տ
    7.  Ï©ï¿½2=�.y5Jj��E�_��d�+�RÙ§
    8. �[=�y�q�n���)������u(>[ÎŽn�m�}L�]�h�M�`�_�Y    %?O�؛ �N��Qf\��
    9. KQ���얣UoB�Țπ��!U ׯ��Nj���OYr�;[w�u�z���F�v-�h� 7���<��˓9�v^|a�_����s�{�!���eτ3`
    10. uδ�y�r��e�K�6��r4קI��J1���a:�ڜc�S��_���2�㢱stE�a���&G,Ö‡ @nEˋ��q3�� 7�(Yd��T�3�|=�5
    11. ���&&K�ּ��&�{V!z�;*ګ}�-g��=��*+
    12. (@e�R\��X�h1� �/S+����`v�`�Rz��bϤ�%��k#VF��j�7Z��I������<���xI�l���(6dʌ��A��J��>�_�(�?��P`oN��ƨ�<g��Ԝ�D��&z'E����Z�M�[ڟ���?)� ��+ÇŒ"�AC�o.U�&-�l�(Pv" 1����
    13. �(ȍ�� ?�5���ٰ����E{nP�,T���y�yo�Ɲ��z��T�;�����@��Dm�ɭ�|�~���2%{g�*�^�� �|g�q��� z�2�W��>:�+O]�3�    \�36F������{<d�O��UE ��d-����R Ћ&q� �=/j�tbM���������}�����>��{I�gJ�4���'������$p�
    14. �V��A7��9'�}���<
    15. (XLީz��?�b��E��<���o�}��砓UQ���O<�9�L�}(
    16. �$�^⿺��}?t{oF�x�;����$��a�V�T[oF���CĊb,k�.��)9�D@D@D@D@�LF� 0g ���W��z<l]�/�9;��ϩ�J0�H�|�kO�[V fMp���;r5)o�%RG���=�lH�N�AU��[��*��M�%�\ ���5V�u��\�G\ʈ,���Q^�Eݕ�Ҩ�VEe ���ڍ 7^u5̝��Ƹ�
    17. �1����R렸��P�� �� �� �� ���7��S[)P�� x����A�t䂾�>�pI?�]    Y�N�-��-��ڦ���CcoZ
    18. h����|<e�q���ݍ�C=�j�q6K��ЭS�
    19. _���~�C�Ӌx5"q�WԆ���1�?�A�_d\7��T�V���1]A�(:�Q >Ùºy�R��Q��o=    w�:u �8�K gfn���~mO�Ɣ�p��{��W.1n�U3.� 3���3z�bX����.L#n\�;W���9�HpT6�c[�͚J�`Ő����쏲MÒ½v�O�P�_7�̪O$�/J�� &n�Pt�6=f��� ���� A�)Z�E��oS>>�Æz��z�;G�6�Pr'h�N
    20. v�b" " " " a�_��tB�5?9�6Oo?Q���y����2躑w��9;#A|b y����z�ŽF��,WI+3��� 1   H�P��$
    21. �  ����h
    22. c�:���iH���� ����G�3;�6�p�)�z�R�-OZrv'9��˝Ҽ�$��79��ge1� �S����M�    -�W&�M� -�Sg�p�HHAk8k+$��S�d��h[!-�7
    23. H����ڝ�|=&|�>�:�;��~��y�7�l�J�r�Xr
    24. ��F#�
    I'm confused lol...
     
  6. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    take this and paste it in an empty txt file, save and rename to jpg... ;) you'll see a wonderfull image...
    technicaly, you're code is working o_O
     
  7. turato

    turato Level III

    Joined:
    Aug 3, 2007
    Messages:
    408
    Likes Received:
    0
    Well lol, I tried it before and this is the error I got (when trying to open with paint):
    "C:\Neopets\ImageTest.jpg
    Paint cannot read this file
    This is not a valid bitmap file, or its format is not currently supported."

    And if I try to store to a bitmap variable I get "Parameter not valid"

    What should I do?

    (I greatly appreciate your assistance, thank you)
     
  8. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    the problem is it's not a bitmap...

    here's what my function looks like



    Code (Text):
    1. Public Function GrabPic(ByVal strURL As String) As System.Drawing.Image
    2.         Dim memStream As New MemoryStream(System.Text.Encoding.Default.GetBytes(StripHeaders(Request("GET", strURL, LastPage))))
    3.         GrabPic = Image.FromStream(memStream)
    4.         Return GrabPic
    5. End Function
    and this goes with this

    Code (Text):
    1. Public Function StripHeaders(ByVal strSource As String) As String
    2.         Dim strParts() As String = Regex.Split(strSource, Environment.NewLine + Environment.NewLine)
    3.         Return strParts(1)
    4.     End Function