1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HELP Clicking Button

Discussion in 'Visual Basic .NET' started by ronstylistic386, Aug 30, 2011.

  1. ronstylistic386

    ronstylistic386 Junior Member

    Joined:
    Mar 28, 2011
    Messages:
    198
    Likes Received:
    366
    Home Page:
    Hi

    I am a newbie on httpwebrequest and I want to know how to click a button using httpwebrequest.

    please help. the button name="submit" id="submit"
     
  2. shudogg

    shudogg Regular Member

    Joined:
    Sep 23, 2008
    Messages:
    412
    Likes Received:
    153
    Occupation:
    Internet Marketing
    Location:
    Indiana
    Home Page:
    You don't click buttons using HTTPWebRequest!

    The code you gave was for a submit button, which would be located inside a form. You need to construct a POST string to submit using HTTPWebRequest.

    Use Firefox and HTTP Live Headers plugin, or Fiddler, or HTTPDebugger... anything to capture packets. After you fill the form and click the submit button, wait for the next page to finish loading and then stop capturing packets. Look for the packet that contains your action. It will have the url your posting to, and the data that was posted, as well as header information..

    You are "emulating" this.

    Just like on wordpress blogs, bots using HTTPWebRequest are actually POSTing the data to wp-comments.php even though the user is on somesite.com/blog-post/.

    Just google "visual basic net httpwebrequest fill form" or something like that, and you will find your answers ;)
     
    • Thanks Thanks x 1
  3. NTG98

    NTG98 Junior Member

    Joined:
    May 27, 2009
    Messages:
    128
    Likes Received:
    12
    Occupation:
    Student
    Location:
    Texas
    How would someone click a button that appears to be somehow loaded in javascript? I've done standard POST form automation, but in terms of actually going in and simulating a user, well, I'm a bit lacking in that area.

    Here is the exact page I am trying to automate a signup for if anyone would care to look: https://www.sparknotes.com/account/signup

    I want to click that big "Create Account" button, but it doesn't look like a normal POST form that I see on blogs or forums, so I want to learn a language that allows me to tackle sites like this.
     
  4. Hydrogen

    Hydrogen Newbie

    Joined:
    Dec 30, 2009
    Messages:
    39
    Likes Received:
    23
    Occupation:
    Co-Owner of AdvertMarketing
    Home Page:
    I checked this over and I didn't see any 'Real' counter-measures in place to prevent bot signups.

    Here is what I found. I used Fiddler but you can use this or LiveHTTPHeaders Plugin for Firefox

    I COMMENTED everything so you would know what it was / used for

    Code:
    https: //www[DOT]sparknotes[DOT]com/account/signup <- FULL URL OF THE FORM SUBMISSION (REPLACE [DOT] with .)
    
    POST /account/signup  <- PATH FORM WAS SUBMITTED TO
    
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) <- THIS IS FIREFOX USER AGENT
    Referer: https: //www[DOT]sparknotes[DOT]com/account/signup <-- SET THIS AS REFERRER (REPLACE [DOT] with .)
    
    email=(URL ENCODED EMAIL ADDRESS)
    &email_confirm=SAME AS ABOVE
    &nickname=DESIRED USERNAME
    &password=PASSWORD 'MUST CONFORM TO THEIR PASSWORD STANDARDS'
    &password_confirm=SAME PASSWORD AS ABOVE
    &birthday%5Bmonth%5D=REPLACE WITH MONTH DIGIT
    &birthday%5Bday%5D=REPLACE WITH DAY DIGIT
    &birthday%5Byear%5D=REPLACE WITH 4 DIGIT YEAR
    &gender=EITHER M OR F for male or female
    &submit.x=179 BS MOUSE LOCATION WHEN CLICKING THE SUBMIT BUTTON LEAVE AS IS
    &submit.y=10 BS MOUSE LOCATION WHEN CLICKING THE SUBMIT BUTTON LEAVE AS IS
    &country=TWO LETTER COUNTRY CODE (IE. US)
    &zipcode=+5 DIGIT ZIP CODE
    &display_email=on USE 'on' or NOTHING to enable or disable this feature
    &notify_friend=on USE 'on' or NOTHING to enable or disable this feature
    &newsletter=on USE 'on' or NOTHING to enable or disable this feature
    &sponsor=on USE 'on' or NOTHING to enable or disable this feature
    &social_link= LEAVE BLANK
    
     
  5. hotleatherdreams

    hotleatherdreams Registered Member

    Joined:
    Mar 29, 2010
    Messages:
    78
    Likes Received:
    18
    Occupation:
    ecommerce website CODER - SUCK at design and SEO
    Location:
    third rock from hell
    Do you guys have access to Web Browser controls?? (just the first paragraph is copied from v b for ums...)First of all the webbrowser control is not one of the controls that come by default in the control box. All you have to do to add it there is to press Ctrl + T key or (Project -> Components using the menu). Once in the components select window, scroll down and check the box next to "Mixrosoft Internet Cuntrols" and click ok.


    I use vb6 so i have no clue if that ^^ means anything to you. Anyhow, WebBrowser1 internet control gives you a full IE browser to do with as you wish. From there its easy street... I am just going to thow out some code that has worked for me in the past, pm any questions, and check this out, its where i got started scraping MANY years ago... help: //wwjd vb-helper c0m/howto_read_freecell.html <-- that will tell you how to click that juicy create account button in any windows machine ;)

    Code:
     
    For Each a In Me.webbrowser1.Document.All.getelementbyname("user1")
       a.Value = textbox1.text ' might set the username from text1 to an input for some website
    Next a
    Me.webbrowser1.Document.Form(2).submit ' this might submit the form you want on that sparkything (3rd form on the page)
    With WebBrowser1.Document.All("Submit").Click ' if your lucky enough to find a lonely submit button
    ' SOME API TO MOVE THE MOUSE AND CLICK IT IF YER DESPERATE - go ask dan appleman if u need help
            Call SetCursorPos((VARIABLEA + 400), (VARIABLEB + 390))  ' move the mouse
            mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, cButt, dwEI 'left mouse click
            mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, cButt, dwEI
     
     
    
     
  6. Hydrogen

    Hydrogen Newbie

    Joined:
    Dec 30, 2009
    Messages:
    39
    Likes Received:
    23
    Occupation:
    Co-Owner of AdvertMarketing
    Home Page:
    My head just exploded reading that you 'suggested' even loading the browser control. -- Ouch I need to go lay down after that.