avidovi Posted August 3, 2015 Share Posted August 3, 2015 Hello all,I am trying to enter some data to an existing web site. after investigating i realized the the form does not have a name. therefore i cannot enter the data automatically,or identify the input or select field.in my code i can see the labels but i cannot differentiate between one another.#include<IE.au3> #include <Array.au3> $sURL="http://www.tailor4less.com/en-us/checkout/measures/?step=start" $oIE=_IECreate($sURL,0, 1, 1, 1) $colForms = _IEFormGetCollection ($oIE) For $oForm In $colForms ; loop over form collection ConsoleWrite("---- FORM " & $oForm.name & " --------------------" & @CRLF) $oFormElements = _IEFormElementGetCollection($oForm) ; get all elements For $oFormElement In $oFormElements ; loop over element collection If StringLower($oFormElement.tagName) == 'input' Then ; it is an input ConsoleWrite("> input." & $oFormElement.type & " " & $oFormElement.name & @CRLF) _IEFormElementSetValue($oFormElement, "2", 0) ; set value of the field ElseIf StringLower($oFormElement.tagName) == 'textarea' Then ; it is a textarea ConsoleWrite("> textarea." & $oFormElement.type & @CRLF) _IEFormElementSetValue($oFormElement, "1", 0) ; set value of the field ElseIf StringLower($oFormElement.tagName) == 'select' Then ; it is a select ConsoleWrite("> select." & $oFormElement.type & @CRLF) _IEFormElementOptionSelect($oFormElement,"4") EndIf Next Next Thanks in advance...Regards, source.txt Link to comment Share on other sites More sharing options...
mikell Posted August 3, 2015 Share Posted August 3, 2015 $form = _IEFormGetObjByName($oIE, "measure_wizard_form") $name = _IEFormElementGetObjByName($form, "title") _IEFormElementSetValue($name, "mikell") $height = _IEFormElementGetObjByName($form, "feet") _IEFormElementOptionSelect($height, "6") _IEFormElementRadioSelect($form, "straight", "param_shoulders") ; etc avidovi 1 Link to comment Share on other sites More sharing options...
avidovi Posted August 3, 2015 Author Share Posted August 3, 2015 Thank you very much my friend.how did you get the form name?? Link to comment Share on other sites More sharing options...
mikell Posted August 3, 2015 Share Posted August 3, 2015 It was written in the source code Hint : you can use name or id indifferently<form method="post" id="measure_wizard_form"> Link to comment Share on other sites More sharing options...
avidovi Posted August 3, 2015 Author Share Posted August 3, 2015 it was way to high, in the inspect element in the browser it was the whole page! Link to comment Share on other sites More sharing options...
avidovi Posted August 3, 2015 Author Share Posted August 3, 2015 OK!!!thanks to u mikell i have managed to enter data from excel file by a loop.now i need to retrieve the data. i wanted to use _IEFormElementGetValue, but it shows me only the object and not the form.any ideas? many thanks. Source.txt Link to comment Share on other sites More sharing options...
mikell Posted August 3, 2015 Share Posted August 3, 2015 The problem is that these values aren't present in the inputs (source code) because they are internally javascript-generatedso I had a little try in the site to get some more infos ... and found the values you're looking for in a json part at the bottom of the page<script type="text/javascript">ga_callbacks.push(['set','dimension4','wizard_D']);var num_measures_required='7';ga_callbacks.push(['set','dimension6',num_measures_required]);ga_callbacks.push(['set','dimension7','man_jacket']);var options={'region':'en-us','gender':'man','product_type':'','profile':{"next":"1.0","id_shop_customer_profile":"","id_profile_manager":null,"gender":"man","measures_calc":null,"constitution":null,"title":"mikell","height":"180","weight":"80","param_shoulders":"normal","param_abdomen":"normal","param_chest":"normal","param_stance":"normal","body_length":"77.6","sleeves_length":"64.5","shoulders":"48.9","chest":"103.3","stomach":"93.5","hips":"102.1","biceps":"33.6","length_units":"cm","weight_units":"kg","profile_name":"mikell"},etc etcThen to get the data you must grab the html source and extract them using a nice little regex avidovi 1 Link to comment Share on other sites More sharing options...
avidovi Posted August 3, 2015 Author Share Posted August 3, 2015 thanks mikell you have been very helpful Link to comment Share on other sites More sharing options...
avidovi Posted August 4, 2015 Author Share Posted August 4, 2015 Hi Mikell, i am trying to pull out the JSON file that you motioned.i tries all bunch of function but none of them are getting me the results i wanted.i used:_IEBodyReadHTML, _IEBodyReadText, _IEDocReadHTML, _IEFormGetObjByName. Link to comment Share on other sites More sharing options...
mikell Posted August 6, 2015 Share Posted August 6, 2015 This way could be a workaround - sort of$w = "150" $h = "6" $url = "http://www.tailor4less.com/en-us/man/measures/estimate?weight_units=lb&length_units=in&weight=" & $w & "&height=" & $h & _ "x¶m_stance=normal¶m_chest=normal¶m_abdomen=normal¶m_shoulders=normal&body_length=0&sleeves_length=0&shoulders=0&chest=0&stomach=0&hips=0&biceps=0" $hr = ObjCreate("WinHttp.WinHttpRequest.5.1") $hr.Open("GET", $url) $hr.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1") $hr.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") $hr.SetRequestHeader("Referer", "http://www.tailor4less.com/en-us/checkout/measures/?step=measures") $hr.Send() If $hr.Status = 200 Then $r = $hr.ResponseBody() FileWrite("1.txt", $r) EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now