|
-
Dec 22nd, 2001, 12:23 PM
#1
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.
-
Dec 22nd, 2001, 12:37 PM
#2
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.
-
Dec 22nd, 2001, 12:55 PM
#3
Frenzied Member
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:
http://www.m-w.com/cgi-bin/dictionary/dictionary?book=dictionary&va=flowers
-
Dec 22nd, 2001, 12:59 PM
#4
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.
-
Dec 22nd, 2001, 01:02 PM
#5
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:
Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Dim sHtml As String
Dim hFile As Integer
sHtml = "<html><body><form name=""dict"" method=""post"" " & _
"action=""http://www.m-w.com/cgi-bin/thesaurus"">" & _
"<input type=""hidden"" name=""book"" value=""Thesaurus"">" & _
"<input type=""hidden"" name=""va"" value=""" & Text1.Text & """>" & _
"<script language=""javascript"">document.dict.submit();</script>" & _
"</form></body></html>"
hFile = FreeFile
Open "c:\tmp.htm" For Output As #hFile
Print #hFile, sHtml
Close #hFile
ShellExecute Me.hwnd, "Open", "c:\tmp.htm", "", "", vbNormalFocus
End Sub
Best regards
-
Dec 22nd, 2001, 01:08 PM
#6
... or you could just use a GET method instead of a POST as showed by Bloodeye 
I feel a little bit stupid right now
-
Dec 22nd, 2001, 01:12 PM
#7
Frenzied Member
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.
-
Dec 22nd, 2001, 01:16 PM
#8
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.
-
Dec 22nd, 2001, 03:21 PM
#9
-
Dec 23rd, 2001, 03:57 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|