Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit data to third party web site

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
0
0
GB
I have a VB application maintaining data that, ideally, I would like to submit to a specific web site at the click of a button. However, I have no control over the design, content or underlying logic of the web-site which is operated by a third party – I simply want to complete a number of fields on an on-line form within the site then submit without user intervention.

I have experimented with the Shell command to connect to the web site and SendKeys to navigate via TAB’s to the relevant fields and have some success in both activating the web site in Explorer and in submitting a username and password. However, I cannot access some fields using SendKeys & TAB no matter how hard I try.

Is there a better way of doing this or is there a way of getting to the appropriate button/field without using TAB? I have considered using API & SetCursorPos but I suspect that this would not really be practical to implement as Window sizes and co-ordinates would vary for different users.

Thanks in advance.
 
Hi,

Are you sure that you can't construct the URL for the COMPLETED form and send it off to the website? I have used this technique in the past - sometimes it is just a matter of studying the names of textboxes and the action that is called by the submit button and/or looking at the URL when you have clicked the submit button.

This can go wrong in all sorts of ways, of course. Session variables for security for instance. But on simpler websites it will often succeed.

Good luck.

Jonathan C
 
I won't pretend to be any expert but I don't think this site is simple - the html is minimal and refers to a Java Script. I assume I cannot view the Java source?

I therefore can't 'see' the names of the textboxes or see the url generated on submit.

 
Are you sure about this?

If the form displayed is a Java applet, then I could understand it, but (thankfully) that is getting uncommon. If it is HTML then you should be able to see everything. For instance, View-Source tells me that the box in which I am typing this is called "post" - I can see the item TEXTAREA COLS="60" ROWS=14 NAME="post" WRAP="virtual".

Java Script might be used on the page to process buttons etc, but by the time you see it in your browser it won't be being used to actually display the form.

Is the site public such that you can put a link to it on tek-tips? Then I'd have a quick browse to see what you're seeing.

JonathanC



 
While the website is public, I could be stepping out of line by including a link - otherwise I'd be really glad of your input. However, when I view source I see something like:

<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot; SRC=&quot;hidden.js&quot;></SCRIPT>
<html>
<head>
<title>Blah blah</title>
<META AUTHOR=&quot;Blah blah&quot;>
<META COPYRIGHT=&quot;Copyright (c) 2002 by Blah Blah&quot;>
<META KEYWORDS=&quot;blah,blah&quot;>
</head>
<frameset rows=&quot;*&quot;>
<frame name=&quot;main&quot; scrolling=&quot;yes&quot; noresize target=&quot;main&quot; src=&quot;./fred_index.html&quot;>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</html>


That's it! There are two text boxes on the page in question. Do I need to be able to view fred_index.html perhaps and is this possible?
 
HTML Frames - I do love 'em!

You're seeing the FrameSet, which includes src=&quot;./fred_index.html&quot; which is probably the actual page. To see the HTML page with the form, right-mouse click on the form and view source. That should be more helpful.

I also respect the issues about not putting the link in here.

Best wishes,

JonathanC
 
OK Jonathan - this works on some pages, thanks. On one of the pages, I get a 'function disabled' message as soon as I right click which I think had been throwing me off the track. I'll explore further but I have an HTML learning curve ahead!
 
Me again, sorry to hassle you!

Once I have determined the names of the fields required from the HTML, can you give me any tips on how to construct the required URL that will bypass the input?
 
HTML is not a particularly bad learning curve, so you shouldn't be too scared if you need to start on it.

The submit URL will be of the form
&quot;http:&quot; becomes https: if the website is secure
&quot;server&quot; will be the website &quot;program&quot; will be name of the program - often with a path at the beginning. Frequently it will end .asp (ActiveServerPage), .jsp (Java Server Page), .cfm (ColdFusion, as on tek-tips), .dll (Dynamic Link Library)

The data your sending is in pairs of argument and value. The values are plain text, except that spaces are replaced with + signs, and much of the punctuation becomes escaped hexadecimal values. Ampersand is used between arguments.

So here is a valid URL that could have worked.


Good luck...
 
Here is a worked example!

The BBC website (I pay my licence fee, so I feel allowed to abuse it!) has a search form including the following bits of HTML

<form name=&quot;toolform&quot; action=&quot;/cgi-bin/search/results.pl&quot;>
<input type=&quot;text&quot; name=&quot;q&quot;>

So we can put together a URL as follows -


That URL should take you straight into the site without it caring that you just arrived there.
 
Thanks Jonathan - this is the track I was starting to head down and it is good to have confirmation. Inevitably, of course, it ain't working but I'm probably doing something dumb so will struggle on.

I'll try not to hassle you further!
 
Yes - the download of hidden.js works, thanks. It contains virtually nothing! However, I have got around a few problems by doing 'File', 'Save As' in Explorer and looking at HTML.

I know I promised not to hassle further but I lied! As a 'neutral example' any suggestions as to how I might go about completing the form at programatically or via a single URL would be greatly appreciated.
 
Hmm. Maybe the URL hacking is not going to work!

Thinking about your original SendKeys approach, it seems practical to me. I write a VB form with a WebBrowser control in it, and write code as follows. It is delicate code - the precise number of tabs (32 in the example below) will vary as the site is changed, for instance.

I can't see which keys will not be sent - I have succeeded in the down-arrow, tab and return keys happily.

By the way, I've sent phasesoftware.co.uk an email telling them this is going on - if its not your site then they might consider this a malicious hack.

Sub FillInFormAndSend()
url = &quot; WebBrowser1.Navigate url
WebBrowser1.SetFocus
For i = 1 To 32
SendKeys &quot;{TAB}&quot;
Next

SendKeys &quot;Tony Blair{TAB}&quot;
SendKeys &quot;Tony.Blair@govt.uk{TAB}&quot;
SendKeys &quot;{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{TAB}MyDSO{TAB}&quot;
SendKeys &quot;10 Downing Street{ENTER}Whitehall{ENTER}London{TAB}&quot;
SendKeys &quot;SW1A 1AA{TAB}&quot;
SendKeys &quot;020 2222 3333{TAB}&quot;
SendKeys &quot;12345678{TAB}&quot;
SendKeys &quot;12{%}{TAB}&quot;
SendKeys &quot;No comment{TAB}&quot;
SendKeys &quot;{ENTER}&quot;
End Sub
 
Aaaaa Just when I was getting all excited about the URL hack method!!

Your efforts are appreciated! You didn't happen to make an attempt via 'the hack option' using XX YY as name, a@b as email and x in most other fields did you? If so, that one worked. Maybe that was the one you did via SendKeys approach.

I had also started looking at the WebBrowser control so may try and take that route further.

Needless to say legal action on your 'malicious hack' is unlikely! Thank you Jonathan - I owe you a pint (or six).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top