I've searched the forum and didn't find what i need.
I am using an INPUT fuction to get input from a user and post the INPUT to a webform using HTTPRequest and get the response back and put it into a variable.
But the results variable contains the entire html for the webpage and I only want the result from the web form - not the rest of the HTML.. (e.g. I only want the "answer" that the webform gives based on the users response).
Any ideas?
Using HTTPRequest to post to Webform and filtering results??
Moderators: Dorian (MJT support), JRL
Re: Using HTTPRequest to post to Webform and filtering resul
Hi clickfast,
- Add one to that starting position, save value in variable "answer_char_start"
- Use the MidStr> command to extract a substring starting at char position answer_char_start and set the length to long as you need... 2, 4, 10, 100... whatever the max length of your "answer" might be... store it in a new variable "answer"
- Now parse your answer variable to clean it up based on whatever rules you can come up with. Perhaps an ending HTML tag always appears right after the answer text. If so, do the same as above only find the starting char position of that HTML tag, minus 1 from that number and now that number is the length of just your answer... so extract another substring from "answer" and this time, it will contain only your answer, nothing else.
I hope this was helpful. If you still have trouble with this and want further help, post all or a section of the text in your "results variable" and I'm sure someone here can give you further tips on how to best parse it.
I believe the "answer" you are seeking is buried within your results variable so build yourself some code to parse it. I don't know exactly what your variable contains but let's say it contained these characters somewhere within it:clickfast wrote:But the results variable contains the entire html for the webpage and I only want the result from the web form - not the rest of the HTML.. (e.g. I only want the "answer" that the webform gives based on the users response).
Any ideas?
- The Answer Is: 42
- Add one to that starting position, save value in variable "answer_char_start"
- Use the MidStr> command to extract a substring starting at char position answer_char_start and set the length to long as you need... 2, 4, 10, 100... whatever the max length of your "answer" might be... store it in a new variable "answer"
- Now parse your answer variable to clean it up based on whatever rules you can come up with. Perhaps an ending HTML tag always appears right after the answer text. If so, do the same as above only find the starting char position of that HTML tag, minus 1 from that number and now that number is the length of just your answer... so extract another substring from "answer" and this time, it will contain only your answer, nothing else.
I hope this was helpful. If you still have trouble with this and want further help, post all or a section of the text in your "results variable" and I'm sure someone here can give you further tips on how to best parse it.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Re: Using HTTPRequest to post to Webform and filtering resul
Thanks jpuziano... will give this a try
jpuziano wrote:Hi clickfast,
I believe the "answer" you are seeking is buried within your results variable so build yourself some code to parse it. I don't know exactly what your variable contains but let's say it contained these characters somewhere within it:clickfast wrote:But the results variable contains the entire html for the webpage and I only want the result from the web form - not the rest of the HTML.. (e.g. I only want the "answer" that the webform gives based on the users response).
Any ideas?
- Use the Position> command to find the starting position of "The Answer Is: " within the variable
- The Answer Is: 42
- Add one to that starting position, save value in variable "answer_char_start"
- Use the MidStr> command to extract a substring starting at char position answer_char_start and set the length to long as you need... 2, 4, 10, 100... whatever the max length of your "answer" might be... store it in a new variable "answer"
- Now parse your answer variable to clean it up based on whatever rules you can come up with. Perhaps an ending HTML tag always appears right after the answer text. If so, do the same as above only find the starting char position of that HTML tag, minus 1 from that number and now that number is the length of just your answer... so extract another substring from "answer" and this time, it will contain only your answer, nothing else.
I hope this was helpful. If you still have trouble with this and want further help, post all or a section of the text in your "results variable" and I'm sure someone here can give you further tips on how to best parse it.
Re: Using HTTPRequest to post to Webform and filtering resul
Excellent, let us know how you do... and if you get it working, please consider posting your code for the benefit of other users as this seems like something of general interest.clickfast wrote:Thanks jpuziano... will give this a try
Thanks and take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -