Sign in to follow this  
Followers 0
scatterp

https auto form filling

13 posts in this topic

Hi

I am new to autoit i have basic programing experience i was trying to make something that would take a long list of words

and post them to https://adwords.google.com/select/TrafficEstimatorSandbox i want to select USD = 100 all languages all countrys

and have the keyword list in a file (5000 keywords) then i want to download the results as a csv file

i am trying to do this from command line can any one help me with this

note i am in the freenode irc channel

irc://irc.freenode.net/autoit

Share this post


Link to post
Share on other sites



There is a UDF for http(s) - see my sig for a pointer - but unless speed is the primary driver, I would use IE.au3. See the helpfile for examples and look at _IECreate, _IEFormGetObjByName, _IEFormElementSetValue, _IEFormSubmit and _IETableWriteToArray or _IEBodyRead*.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

How to use _IEFormSubmit when the page haves 2 submit buttons? Like thins:

<script>
function proc (){
document.auth.hs.value = hex_h(document.auth.parm.value+document.auth.ht.value);
document.auth.parm.value='';
} 
</script>



<form name="auth" method=post action="page" autocomplete="off">
User: <input name="user" type="text" class="search" size=10>
Pass: <input name="parm" type="password" size=10>
<input type=checkbox name=save onchange=chk()>
<font size=1>remember the user and pass</font>
<input name="hs" type="hidden">
<input name="p" type="hidden" value="log">
<input name="ht" type="hidden" value=SID>
<input name=bsend value="Login" type="submit" onclick=proc()>
<input name=bsend value="Logout" type="submit" onclick=proc()>
</form>

Share this post


Link to post
Share on other sites

There is a UDF for http(s) - see my sig for a pointer - but unless speed is the primary driver, I would use IE.au3. See the helpfile for examples and look at _IECreate, _IEFormGetObjByName, _IEFormElementSetValue, _IEFormSubmit and _IETableWriteToArray or _IEBodyRead*.

Dale

Hi

thanks i am looking in to it can any one provide me with an example how to change my code to use _IEFormSubmit to take data from a txt file and post it to the box ?

Share this post


Link to post
Share on other sites

There is a UDF for http(s) - see my sig for a pointer - but unless speed is the primary driver, I would use IE.au3. See the helpfile for examples and look at _IECreate, _IEFormGetObjByName, _IEFormElementSetValue, _IEFormSubmit and _IETableWriteToArray or _IEBodyRead*.

Dale

hi i took a look at the udf unfortunately i had already looked at it and did not work out it had https problems

and was far more complexed than i could get a grip on what was going on to edit or work with it

the IE.au3 seems a better option

i was using that in my existing script that i attached

Share this post


Link to post
Share on other sites

heres the code i think needs to change

$oIE = _IECreate ("https://adwords.google.com/select/trafficestimatorsandbox?cmd=TrafficEstimatorSandbox&keywords=" & $ret & "&currency=USD&price=100&budget=&language=*&geoselection=&countryList=*", 0, 1, 1)

some how it needs to read in the text file and then fill out the form instead of doing it the way it is

also instead of retrieving the text it does it needs to download the csv file

#include <GuiConstants.au3>
#include <IE.au3>
#include <String.au3>
#include <array.au3>
#include <File.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GUICreate;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$endf=0
$addtoold=0

;<exefilename> -k test

$ret = _ReadCmdLine("k");
;
; read the command line parameters and return value
;
; options are separated by "-"
;
Func _ReadCmdLine($switch)
If $CmdLine[0] > 0 Then
$Cmdopt = StringSplit($CmdLineRaw, "-"); options are separated by "-"
; _ArrayDisplay($Cmdopt, "options")
; start with 2
For $I = 2 To UBound($Cmdopt) - 1;
$param = StringLeft($Cmdopt[$I], 1); "f" - 1 char
; value is now rest of switch
$value = StringRight($Cmdopt[$I], StringLen($Cmdopt[$I]) - 1); take rest as value
$value = StringStripWS($value, 3);
; found it ??
If $param = $switch And $value <> "" Then
Return $value
EndIf; value F?
Next; all params
EndIf
Return 0; default
EndFunc;==>_ReadCmdLine

;GuiCreate("Traffic Estimator", 220, 200,(@DesktopWidth-191)/2, (@DesktopHeight-157)/2)
;$button1 = GuiCtrlCreateButton("Run", 45, 160, 130, 20)
;GuiSetState()
While 1
;   $msg = GuiGetMsg()
    Select
; Case $msg = $GUI_EVENT_PRIMARYUP
;   Case $msg = $GUI_EVENT_CLOSE Or $endf = 1
;       ExitLoop
 Case $ret = $ret

  $oIE = _IECreate ("https://adwords.google.com/select/trafficestimatorsandbox?cmd=TrafficEstimatorSandbox&keywords=" & $ret & "&currency=USD&price=100&budget=&language=*&geoselection=&countryList=*", 0, 1, 1)
     _IELoadWait ($oIE)
  $Line = _IEDocReadHTML($oIE)
_IEQuit ( $oIE )

$Start =   StringInStr($Line,"<TABLE class=report")
$End   =   StringInStr($Line,"<TBODY></TBODY></TABLE>") - $Start
$HtmlTag = StringMid($Line,$Start,$End)
 
 $Start   = StringInStr($HtmlTag,"noWrap align=right>") + 18
 $End   =   StringInStr($HtmlTag,"<TR bg") - $Start -11

 $HtmlTag = StringMid($HtmlTag,$Start,$End)
 $HtmlTag = StringReplace($HtmlTag,"<TD noWrap align=right>","")
 $HtmlTag = StringReplace($HtmlTag,"<TD","")
 $HtmlTag = StringReplace($HtmlTag,"<TR","")
 $HtmlTag = StringReplace($HtmlTag,"<TH","")
 $HtmlTag = StringReplace($HtmlTag,"</TH","")
 $HtmlTag = StringReplace($HtmlTag,"</TR","")
 $HtmlTag = StringReplace($HtmlTag,"</TD","")
 $HtmlTag = StringReplace($HtmlTag,"<","")
  $HtmlTag = StringReplace($HtmlTag,">","")

 $HtmlTag = StringReplace($HtmlTag,"vAlign=center bgColor=#e8e8cf","")
 $HtmlTag = StringReplace($HtmlTag,"align=leftSearch Network Total","")
 $HtmlTag = StringReplace($HtmlTag,"noWrap align=right","")
  $HtmlTag = StringReplace($HtmlTag,"align=right&nbsp;","")



;~ $HtmlTag = StringReplace($HtmlTag,"<TR>","<TR><TD>" & $Item & "</TD><TD>" & $Stroke & "</TD><TD>" & $Colour & "</TD><TD>" & $Size & "</TD><TD>M&S Requirement</TD>" & "<TD>"& _NowDate() &"</TD>")
;~ $Line = StringMid($Line,$Start+$End)
;~ $Html = $Html & $HtmlTag

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWriteLine($file, $HtmlTag  & @CRLF)
FileClose($file)
Exit

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OpenPage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

How to use _IEFormSubmit when the page haves 2 submit buttons? Like thins:

<script>
function proc (){
document.auth.hs.value = hex_h(document.auth.parm.value+document.auth.ht.value);
document.auth.parm.value='';
} 
</script>
<form name="auth" method=post action="page" autocomplete="off">
User: <input name="user" type="text" class="search" size=10>
Pass: <input name="parm" type="password" size=10>
<input type=checkbox name=save onchange=chk()>
<font size=1>remember the user and pass</font>
<input name="hs" type="hidden">
<input name="p" type="hidden" value="log">
<input name="ht" type="hidden" value=SID>
<input name=bsend value="Login" type="submit" onclick=proc()>
<input name=bsend value="Logout" type="submit" onclick=proc()>
</form>
???

Share this post


Link to post
Share on other sites

???

Please read the "Remarks" for the _IESubmit function. It tells you how to deal with two Submit buttons.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

It sure looks like your code with all the StringReplace's could be done a whole lot easier with _IETableWriteToArray

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

It sure looks like your code with all the StringReplace's could be done a whole lot easier with _IETableWriteToArray

Dale

could you help me with this ?

Share this post


Link to post
Share on other sites

OK, Dale, now show me here how to submit the button? I even don't have a $oForm...

$oIE = _IECreateEmbedded()

GUICreate("login", 600, 400, 0, 0);

GUICtrlCreateObj($oIE,-1,-1,630,570)

GUISetState()

_IENavigate ($oIE, "http://site.com/")

$oUser=_IEGetObjById($oIE,"user")

$oPass=_IEGetObjById($oIE,"parm")

_IEFormElementSetValue ($oUser, $username)

_IEFormElementSetValue ($oPass, $password)

_IEFormSubmit($oIE, 0) Do not works...

The site form is up in this page...

Share this post


Link to post
Share on other sites

Is it possible when i use GUI IE to click on a subbmit button? Because with Send() isn't very good way...

Share this post


Link to post
Share on other sites

@Dido_Net - please start a new thread for your question. It is not related to scatterp's question and makes replies very confusing

@scatterp - have you worked through the _IETableWriteToArray examples in th helpfile? What don't you understand?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0