kram Posted June 19, 2012 Share Posted June 19, 2012 I frequent these forums often, and in the past I've always been able to find the answer to my questions from other user's threads. This time I've hit a wall due to my lack of knowledge in programming/AutoIt, and I was hoping some of you might point me in the right direction. Basically, I have to pull up customer information from an internal web based search tool to obtain their username for emailing purposes. I have almost 1000 people I have to do this for, and the list grows daily, hence my reasoning behind some scripting. The way the search tool was built, I don't think I can isolate the username using _IEFormElementGetObjByName, so I approached the problem using _IEPropertyGet. Here is a snippet of the web tool source, which may or may not help explain what I am seeing and what I need to do (I x'd out any info that might reveal something my employer might not want public): <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>View Account </title> <style type="text/css">@import url(/xxxxxxxx/xxx/xxxx.css);</style> <script language="javascript" src="/xxxxxxxx/javascript/main.js"></script> </head> <body> <div id="cadm-container"> <div id="cadm-content-wrapper" class="column"> <div id="cadm-content-header"> <h2> CADM </h2> <dl id="cadm-user"> <dt> Logged in as: </dt> <dd> xxxxx xxxxxxxxx </dd> </dl> <dl id="cadm-customer"> <dt> Customer: </dt> <dd> customerusernameishere </dd> </dl> I want to isolate everything down to just the username so I can save it to a variable for use in my script. I used an example script from the AutoIt help index: #include <IE.au3> $oIE = _IEAttach ("view") $oDiv = _IEGetObjById ($oIE, "cadm-customer") ConsoleWrite(_IEPropertyGet($oDiv, "innerhtml") & @CRLF) And in the console I get this: <DT>Customer: </DT> <DD>customerusernameishere </DD> How would I isolate just the username to a variable? This is the best approach I've found so far to isolating what I need from all the other junk that is on the web page. Is there perhaps a much easier approach to this? Any help you can give will be much appreciated. Link to comment Share on other sites More sharing options...
BartW Posted June 19, 2012 Share Posted June 19, 2012 (edited) HI, What i will use is _stringbetween. i made a exsampel its maby not going to work but it gifs you a direction #include <IE.au3> #include <String.au3> $oIE = _IEAttach ("view") $TempHTML = _IEBodyReadHTML($oIE) $Firstepart = _StringBetween($TempHTML,"<dl id="&""""&"cadm-customer"&""""&">","</dl>") $Customerpart = _StringBetween($Firstepart[0],"<DT>","</DT>") $CustomerUsernamepart = _StringBetween($Firstepart[0],"<DD>","</DD>") ConsoleWrite("Customer : "&$Customerpart[0]&@crlf&"username : "&$CustomerUsernamepart[0]&@crlf). Edited June 19, 2012 by BartW Link to comment Share on other sites More sharing options...
DaleHohm Posted June 20, 2012 Share Posted June 20, 2012 (edited) #include <IE.au3> $oIE = _IEAttach ("view") $oDiv = _IEGetObjById ($oIE, "cadm-customer") $oDD = _IETagnemGetCollection($oDiv, "DD", 0) ConsoleWrite(_IEPropertyGet($oDD, "innerhtml") & @CRLF) Dale Edited June 20, 2012 by DaleHohm 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 Link to comment Share on other sites More sharing options...
kram Posted June 21, 2012 Author Share Posted June 21, 2012 Bartw and DaleHohm, thank you very much for your help. Not only did the examples work, but it taught me some new things today. I really appreciate you taking some time to help me. 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