Results 1 to 10 of 10

Thread: Page returned from form

  1. #1
    Moon
    Guest

    Page returned from form

    I don't think the subject makes much sense but this is what I need to know:

    In the web page at www.m-w.com there's a place to look up for words in the Collegiate Dictionary. Given a word, I need to know what's the returned web page when I press the "Look it up" button, so I can download the page.

    If someone could explain me how I can generaly know the returned url in these kind of forms, I would apreciate very much.

  2. #2
    hellswraith
    Guest
    Your not going to know, it is a cgi script returning a page. This means that it is the same page being returned, just different content every time based on what you entered in the form. What you can do to save the page is save the source in a html file along with all the pictures. There are freeware programs that are page downloaders.

  3. #3
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    You could also directly navigate to this URL. This is basically what is sent to the Server when you click on the "Look it Up" button. All you need to do is change the value of "va" in the following link. Right now it would "Look up" the word flowers...
    VB Code:
    1. http://www.m-w.com/cgi-bin/dictionary/dictionary?book=dictionary&va=flowers

  4. #4
    hellswraith
    Guest
    Hey bloodeye, that is how to get to the page, not what the page is. He can't save anything from that link itself, because the page isn't created yet.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Yes it's a CGI script. But you can of cource send the information to it.
    The HTML Form on uses a POST method to the script.
    It has two input types. One is the textbox named "va" and the second is hidden and named "book" and has a value of "Thesaurus".

    Try this: Start a new standard EXE project.
    Add a TextBox and a CommandButton to the form.
    Now these controls gimmick the HTML Form.
    So you type some value in the text box and click the button right.
    So in the Click event of the Command Button you create a temporary HTML file that contains a HTML form with the necassary values.
    It should also use a simple JavaScript to automatically submit this form.
    Now in this example I use ShellExecute to run the temp HTML file which will immediately submit the form to www.m-w.com.
    VB Code:
    1. Private Declare Function ShellExecute _
    2.  Lib "shell32.dll" Alias "ShellExecuteA" ( _
    3.  ByVal hwnd As Long, _
    4.  ByVal lpOperation As String, _
    5.  ByVal lpFile As String, _
    6.  ByVal lpParameters As String, _
    7.  ByVal lpDirectory As String, _
    8.  ByVal nShowCmd As Long) As Long
    9.  
    10. Private Sub Command1_Click()
    11.     Dim sHtml As String
    12.     Dim hFile As Integer
    13.     sHtml = "<html><body><form name=""dict"" method=""post"" " & _
    14.      "action=""http://www.m-w.com/cgi-bin/thesaurus"">" & _
    15.      "<input type=""hidden"" name=""book"" value=""Thesaurus"">" & _
    16.      "<input type=""hidden"" name=""va"" value=""" & Text1.Text & """>" & _
    17.      "<script language=""javascript"">document.dict.submit();</script>" & _
    18.      "</form></body></html>"
    19.     hFile = FreeFile
    20.     Open "c:\tmp.htm" For Output As #hFile
    21.     Print #hFile, sHtml
    22.     Close #hFile
    23.     ShellExecute Me.hwnd, "Open", "c:\tmp.htm", "", "", vbNormalFocus
    24. End Sub
    Best regards

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    ... or you could just use a GET method instead of a POST as showed by Bloodeye
    I feel a little bit stupid right now

  7. #7
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Originally posted by hellswraith
    Hey bloodeye, that is how to get to the page, not what the page is. He can't save anything from that link itself, because the page isn't created yet.
    I think hellswraith is right though. You can't directly save this URL as a Web-Page because it hasn't been created yet.....not sure, I've never tried it.

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by Bloodeye

    I think hellswraith is right though. You can't directly save this URL as a Web-Page because it hasn't been created yet.....not sure, I've never tried it.
    Well, as I understand it he wants to know how to get there without filling in the form on the start page so both your and mine code will work to do so.

  9. #9
    Moon
    Guest
    Thank you Bloodeye!
    Your code is exactly what I wanted, now I just need to try it with other sites. This is so great, thanks!

    Joacim Andersson: Sorry, but I'll use Bloodeye's code instead as it's simpler. But I will keep your code. An alternative way to do things is also a good thing. Thank you too!

    Woo hoo! I'm so excited as a little boy!

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by Moon
    Thank you Bloodeye!
    Your code is exactly what I wanted, now I just need to try it with other sites. This is so great, thanks!

    Joacim Andersson: Sorry, but I'll use Bloodeye's code instead as it's simpler. But I will keep your code. An alternative way to do things is also a good thing. Thank you too!
    I've just tested it with an ASP page and Bloodeye's code doesn't work when the form use a POST method.
    However my code did. So it seems like it only works with CGI scripts.

    Best regards

Posting Permissions

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



Click Here to Expand Forum to Full Width