Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 20th, 2009, 04:43 AM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using VBScript to Fill Out a Web Form

Peace all, I am currently trying to use VBScript to fill out a web form (and submit it).
For example, I am using this script.

Code:
 
Set IE = CreateObject("InternetExplorer.Application") 
set WshShell = WScript.CreateObject("WScript.Shell")  
IE.Navigate "http://mylogin.page" 
IE.Visible = True 
Wscript.Sleep 6000 
IE.Document.All.Item("fld_userName").Value = "adley" 
IE.Document.All.Item("fld_password").Value = "password" 
WshShell.AppActivate "IE" 
WshShell.SendKeys "{ENTER}"
My problem is this.
The script above works for most pages, but there are a few exceptions that I hoped someone in this forum would help me.
1. If the connection is sooo slow, the "Sleep" line above is not that effective. Does anyone know a better way, such as a "wait until page completely loaded" function?

2. I am using SendKeys above, but for cases where the web page doesn't necessarilly accept ENTER after filling out the password, I need something else. I encounter this for a web page requiring me to select a value from a drop-down box and click the "Log On" button afterward. I can specify the value to be selected, but sending ENTER (or TAB then ENTER) was useless. I don't know how to set a focus to a web object/field using VBScript.

Any help would be much appreciated. Thanks.

Last edited by adley; January 20th, 2009 at 04:48 AM..
Reply With Quote
  #2 (permalink)  
Old January 20th, 2009, 06:43 AM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peace all,

Never mind.
Solved it.

Thanks.
Reply With Quote
  #3 (permalink)  
Old April 17th, 2009, 01:31 AM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question QUICK QUESTION !!!!!

I'm trying to automate posting to craigslist with my ad that I normally have to post manually (which is a pain in the bottom!). My issue is that I can't get to the text boxes to fill them out in Craigslist since the "{Tab}" is skipping some of the fields. So I used the following code below:

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "https://post.craigslist.org/ahn/S/msg/none/x"
IE.Visible = True
Wscript.Sleep 4000
Document.All.Item("?").Value = "Whatever Message You Want"
IE.Document.All.Item("?").Click

Can someone please fill in the "?" to help answer the question & make the cursor land in the boxes?

Here's the Craigslist page that I'm trying to automate:

https://post.craigslist.org/atl/S/msg/none/x
Reply With Quote
  #4 (permalink)  
Old April 17th, 2009, 02:16 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

A better way to do this would probably be to use the MSXML2.ServerXMLHTTP object to *fully* automate the process, so that the browser window doesn't even pop up.
Reply With Quote
  #5 (permalink)  
Old April 17th, 2009, 12:24 PM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question ???

Quote:
Originally Posted by Old Pedant View Post
A better way to do this would probably be to use the MSXML2.ServerXMLHTTP object to *fully* automate the process, so that the browser window doesn't even pop up.

Thanks for you quick reply. Well I'm new to VBScript & surprised that with what I have already learned, but could you please show me the exact code example and display it the way that I did above so that I will know exactly how to use it. Effective learning. Thanks.
Reply With Quote
  #6 (permalink)  
Old April 17th, 2009, 02:38 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ugh...I should have looked at that URL you posted before opening my mouth.

The problem is, Craiglist apparently generates a unique <FORM> for each and every posting.

For example, I hit the URL once and got a <FORM> that looked like this:
Code:
<form id="postingForm" action="/atl/S/msg/none/x/ERJkQMOKlP0yshV8/y2mi6" 
      method="post" enctype="multipart/form-data">
<input type="hidden" name="postingKey" id="postingKey" value="ERJkQMOKlP0yshV8">
<input type="hidden" name="test" id="test" value="y2mi6">
... and so on ...
So then I hit the same URL again and got a <form> that looked like this:
Code:
<form id="postingForm" action="/atl/S/msg/none/x/PMAzNiDklEgG23zH/i2w9n" 
      method="post" enctype="multipart/form-data">
<input type="hidden" name="postingKey" id="postingKey" value="PMAzNiDklEgG23zH">
<input type="hidden" name="test" id="test" value="i2w9n">
... and so on ...
So it's not at all like filling out a <form> on most sites. Unfortunately.

I think it still could be done, but it's probably a lot more work than the way you were starting to go. So I sincerely apologize for putting both feet firmly between my teeth.

Incidentally, that URL doesn't even produce a response from an MSIE 6 browser! So obviously Craigslist also customizes the URLs to match a specific browser type! Wow. I'm pretty sure I *could* do it the way I suggested, but it's at least a couple of days' work. (With most sites, it's 30 minutes or so.)
Reply With Quote
  #7 (permalink)  
Old April 17th, 2009, 05:18 PM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Just To Make Sure You Understood.....

Please watch this video to see in more detail of what it is that I'm trying to do:

http://www.youtube.com/watch?v=Vv0yiAJiAPY













Quote:
Originally Posted by Old Pedant View Post
Ugh...I should have looked at that URL you posted before opening my mouth.

The problem is, Craiglist apparently generates a unique <FORM> for each and every posting.

For example, I hit the URL once and got a <FORM> that looked like this:
Code:
<form id="postingForm" action="/atl/S/msg/none/x/ERJkQMOKlP0yshV8/y2mi6" 
      method="post" enctype="multipart/form-data">
<input type="hidden" name="postingKey" id="postingKey" value="ERJkQMOKlP0yshV8">
<input type="hidden" name="test" id="test" value="y2mi6">
... and so on ...
So then I hit the same URL again and got a <form> that looked like this:
Code:
<form id="postingForm" action="/atl/S/msg/none/x/PMAzNiDklEgG23zH/i2w9n" 
      method="post" enctype="multipart/form-data">
<input type="hidden" name="postingKey" id="postingKey" value="PMAzNiDklEgG23zH">
<input type="hidden" name="test" id="test" value="i2w9n">
... and so on ...
So it's not at all like filling out a <form> on most sites. Unfortunately.

I think it still could be done, but it's probably a lot more work than the way you were starting to go. So I sincerely apologize for putting both feet firmly between my teeth.

Incidentally, that URL doesn't even produce a response from an MSIE 6 browser! So obviously Craigslist also customizes the URLs to match a specific browser type! Wow. I'm pretty sure I *could* do it the way I suggested, but it's at least a couple of days' work. (With most sites, it's 30 minutes or so.)
Reply With Quote
  #8 (permalink)  
Old April 17th, 2009, 07:34 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I don't think the form, per se, is encrypted. I do think that the *names* of the form fields and the values of certain HIDDEN form fields are encrypted, and that they use that indeed as a way to ensure that you can't just keep submitting the same <form> over and over. Each post you make must be made with a new <form> that you get from them.

And the form field names change on each reload of the page. So your VBS code would have to scan all the fields and figure out, by position, which one is doing what. So you can't just "fill in the ?" as somebody suggested. You first have to figure out what ? is for this particular incarnation of the <form>.

No, I don't know how to do that using the MSIE object scripted by VBS. I think I could do it by "screen scraping", using ServerXMLHTTP, as I suggested. But it's not a trivial task and would take several hours. With no guarantees it works, at the end.

I looked at their JS library and didn't *see* anything doing client-side encryption. Doesn't mean it's not there. But I don't see why it would matter if there is, if you are indeed invoking the browser itself.

I think it's mainly just the field names and then hidden form field values that have to agree to constitute a valid post, so far as their protection software is concerned.
Reply With Quote
  #9 (permalink)  
Old April 17th, 2009, 09:38 PM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Try This Out !!!

Well I understand that you believe the codes change with each download, but I am %110 sure that this can be done as well. Maybe not the same exact source code that I displayed earlier, but there are plenty of software apps out there that can automate posting to Craigslist with 1 simple click of a button. I know that some of those particular web bots were designed in VB 2008.

Here's another VBScript that I wrote that works sometimes, but sometimes just isn't good enough. Try it out and see if you can tamper it into shape:


Code:
 
set a = createobject("wscript.shell")
a.run "https://post.craigslist.org/sfo/S/msg/sfc/9"
wscript.sleep (8000)
a.SendKeys "{TAB 10}"
wscript.sleep (2000)
a.sendkeys ("Whatever ad Title that you want")
a.SendKeys "{TAB}"
a.sendkeys ("10.00 !!!")
a.SendKeys "{TAB}"
a.sendkeys ("Tester123@gmail.com")
a.SendKeys "{TAB}"
a.sendkeys ("Tester123@gmail.com")
a.SendKeys "{TAB 2}"
a.sendkeys ("whatever ad that you want***BZ***: http://store.payloadz.com/results/st...d-results.html")
wscript.sleep (2000)
a.SendKeys "{TAB}"
wscript.sleep (2000)
a.SendKeys "{Enter}"
wscript.sleep (4000)
a.SendKeys "{TAB 10}"
wscript.sleep (2000)
a.SendKeys "{Enter}"
wscript.sleep (4000)
a.SendKeys "{TAB 15}"
wscript.sleep (2000)
a.SendKeys "{Enter}"
call msgbox("Finished")
wscript.quit

This is a pretty cool WEBBOT most of the time, but most of the time isn't good enough either. ;oD

It will get you all the way to the CAPTCHA point most of the time & then you will see the finished box.

**** Don't click any windows while it's in process ***

Please try your best to fix this script to perfection.... Thanks !!!









Quote:
Originally Posted by Old Pedant View Post
I don't think the form, per se, is encrypted. I do think that the *names* of the form fields and the values of certain HIDDEN form fields are encrypted, and that they use that indeed as a way to ensure that you can't just keep submitting the same <form> over and over. Each post you make must be made with a new <form> that you get from them.

And the form field names change on each reload of the page. So your VBS code would have to scan all the fields and figure out, by position, which one is doing what. So you can't just "fill in the ?" as somebody suggested. You first have to figure out what ? is for this particular incarnation of the <form>.

No, I don't know how to do that using the MSIE object scripted by VBS. I think I could do it by "screen scraping", using ServerXMLHTTP, as I suggested. But it's not a trivial task and would take several hours. With no guarantees it works, at the end.

I looked at their JS library and didn't *see* anything doing client-side encryption. Doesn't mean it's not there. But I don't see why it would matter if there is, if you are indeed invoking the browser itself.

I think it's mainly just the field names and then hidden form field values that have to agree to constitute a valid post, so far as their protection software is concerned.
Reply With Quote
  #10 (permalink)  
Old April 18th, 2009, 12:48 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, I'm done here. Maybe somebody else will comment.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill out a web form mendy VB How-To 19 March 31st, 2015 02:28 PM
How to fill the IE's web page forms from VB? JohnThomas VB How-To 1 April 19th, 2009 06:53 AM
Fill datasheet/Continuous form with vba code only Galateo Access VBA 0 May 9th, 2008 09:39 AM
Which is the web site that teachs VBScript ? Hoang2005 Excel VBA 1 March 10th, 2006 08:09 AM
auto-fill form crmpicco HTML Code Clinic 2 April 21st, 2005 06:42 AM



All times are GMT -4. The time now is 09:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.