Consulting

Results 1 to 1 of 1

Thread: Sending Post Data using IE control

  1. #1

    Sending Post Data using IE control

    So I'm having a problem sending some post data to a site and returning the results. Im using vba through word right now to run this code. I'm opening a new IE window, navigating to a site and trying to send post data. However, this site doesn't seem to like the code I've written. I've done it before on other websites so I'm not new with this. Is there something wrong with the code or something about sending requests to websites that i'm not realizing? here's the code snippet:

    Dim URL As String, PostData() As Byte, PostData2() As Byte
    Dim wb As Object
    'open the IE and set to blank
    Set wb = CreateObject("InternetExplorer.Application")
    With wb
    .navigate "about:blank"
    .Height = 400
    .Width = 400
    .ToolBar = 0
    .MenuBar = 0
    .Visible = True
    End With
    URL = "h t t p ://zip4.usps.com/zip4/zcl_0_results.jsp"
    Dim address2 As String, city As String, state As String
    address2 = "12 autumn ln"
    city = "ewing"
    state = "nj"

    PostData = "address2=" & address2 & "&address1=&city=" & city & "&state=" & state & "&zip5=" & zip5
    PostData2 = "visited=1&pagenumber=0&firmname=&" & "address2=" & address2 & "&address1=" & address1 & "&city=" & city & "&state=" & state & "&urbanization=" & "&zip5=" & zip5
    PostData2 = StrConv(PostData2, vbFromUnicode)
    wb.Silent = True
    wb.navigate URL, Null, "", PostData, "Referer: h t t p ://zip4.usps.com/zip4/welcome.jsp"
    'While wb.ReadyState < 4
    ' Sleep 100
    'Wend
    'nevermind the links being spaced out, i did that so i could post

    This code isn't generating errors through VB, but it isn't returning what I want. I've tried sending PostData as well as PostData2 (1 includes only the inputs that are visible on the page, the other includes all inputs except the submit button - wasnt sure if this mattered so i tried it both ways)
    Also, i tried setting the referer field as a header because my result wasn't loading correctly without this and i thought maybe they blocked external servers from sending post data. My guess is they've blocked external servers in one way or another and I just don't know enough about the internet these days to know how or why. Any help is much appreciated.

    FYI the site im starting from is h t t p : \ \ zip4.usps.com/zip4/welcome.jsp (cant submit links, too few posts)
    and id like to have a program that fills out the fields and hits submit. I'd much rather have the program send the request on its own, though, than have it load the first page, populate the fields, and then hit submit. that's time wasted. however, i see that may be my only option.
    Last edited by benicillin; 03-31-2009 at 06:43 AM.

Posting Permissions

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