Read file and post results to Web Form using HTTPRequest

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Read file and post results to Web Form using HTTPRequest

Post by clickfast » Mon Dec 03, 2007 4:02 pm

I'm sure i'm probably just overlooking something simple...

I want to read a simple text file of numeric values each on their own line in a text file and i want to post each value to a web form...

I got the ReadLn loop part down I just can get MS to send to webform properly...

I posted an example below.

What am I doing wrong??? Thanks!!

Code: Select all

Let>k=1
Label>start
ReadLn>d:\data\datafile.txt,k,line
If>line=##EOF##,finish
HTTPRequest>http://www.webformsite.com/index.php,,POST,%line%,testpost,,,,
Let>k=k+1
Goto>start
Label>finish
Last edited by clickfast on Mon Dec 03, 2007 11:08 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 4:48 pm

HTML forms require parms in this format:

VARNAME1=VALUE1&VARNAME2=VALUE2&VARNAME3=VALUE3 etc

So you need to do a bit extra to convert your CSV data
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 5:06 pm

Can you provide an Example?
Last edited by clickfast on Mon Dec 03, 2007 11:09 pm, edited 3 times in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 5:07 pm

I can't provide an example as I don't know what the form field names are, or how these match up to your CSV. If you send me the form spec (or html) and your CSV and tell us how both should match up we might be able to provide some example code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 5:41 pm

I have a simple Text file called list.txt with the following values

43243289
23427456
4360928234
0890877896
30897972

I want to post them to the following form

Here's the HTML snippet for the form
......

function CheckFid() {
var filter = /^[0-9]/;
if(!filter.test(document.getElementById('fid').value))
{
alert("Your Id should only contain numbers!");
document.getElementById('fid').value = '';
document.getElementById('fid').focus();
return false;
}
}


.....


Last edited by clickfast on Mon Dec 03, 2007 11:40 pm, edited 7 times in total.

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 8:36 pm

THANKS
Last edited by clickfast on Mon Dec 03, 2007 10:13 pm, edited 2 times in total.

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Re: Read file and post results to Web Form using HTTPRequest

Post by clickfast » Mon Dec 03, 2007 8:40 pm

ANYONE?
Last edited by clickfast on Mon Dec 03, 2007 11:34 pm, edited 3 times in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 8:46 pm

Clue: Look at the source of the page. Find the form tag and then the input tag for the search box. Discover that it is called "fid" (name="fid"). So the parameter is fid. So our POST parm is just fid=value. Note the action attribute of the form tag (action="join.php"). So the form posts to join.php. (not index.php as you have). So.

Code: Select all

Let>k=1
Label>start
  ReadLn>d:\data\datafile.txt,k,line
  If>line=##EOF##,finish
    Let>post_data=fid=%line%
    HTTPRequest>http://www.ssfriendship.com/join.php,,POST,%post_data%,testpost,,,,
  Let>k=k+1
  Goto>start
Label>finish
Last edited by Marcus Tettmar on Mon Dec 03, 2007 11:07 pm, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 10:09 pm

thanks Marcus

mtettmar wrote:Clue: Look at the source of the page. Find the form tag and then the input tag for the search box. Discover that it is called "fid" (name="fid"). So the parameter is fid. So our POST parm is just fid=value. Note the action attribute of the form tag (action="join.php"). So the form posts to join.php. (not index.php as you have). So.

Code: Select all

Let>k=1
Label>start
  ReadLn>d:\data\datafile.txt,k,line
  If>line=##EOF##,finish
    Let>post_data=fid=%line%
    HTTPRequest>http://www.websiteformcom/join.php,,POST,%post_data%,testpost,,,,
  Let>k=k+1
  Goto>start
Label>finish
Last edited by clickfast on Mon Dec 03, 2007 11:18 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 10:42 pm

Why have you deleted your previous posts? Please leave questions to answers intact so that others can learn from the threads.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 11:02 pm

Sorry, (SEE THE PM I SENT YOU) you mentioned SPAM and my client panicked that i posted his site explicitly on here. Because this forUm is viewable by the public, anyone could've gotten a hold of this code and misused it against my clients site.

However, I was careful to only remove the private info. The jist of this post remains in tack.

Essentially what I've learned is you have to identify the form id and use the HTTPRequest param with the form id to post a variable from macroscheduler to the webform.

This was a Big Help!


mtettmar wrote:Why have you deleted your previous posts? Please leave questions to answers intact so that others can learn from the threads.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 03, 2007 11:11 pm

If by "private info" you mean the website URL, it' still here. A website URL is hardly private. It is a public website after all. The website was necessary to help identify the form action and form field. And linking to it will help other see how I came up with the provided code.

Your client's web site source is viewable to anyone with a web browser. So nothing has been revealed here that isn't already publicly available. Those wanting to automatically submit data to that site will not need info here to do that. Any web developer already knows how to do that.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Post by clickfast » Mon Dec 03, 2007 11:23 pm

I didn't' realize this was code that could be used to build a spam-bot, so I wanted to be sure I didn't give out the keys to my house so to speak.

I put in the the HTML form info from the source code above so users can follow the logic of this thread

THANKS A MILL



:wink:
Last edited by clickfast on Mon Dec 03, 2007 11:41 pm, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Dec 03, 2007 11:25 pm

[site name omitted] is a website that you can use to get hundreds or thousands of real friends a day!

I'll never understand web 2.0 :roll:

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts