Rogue5099 Posted March 27, 2012 Share Posted March 27, 2012 (edited) This is just to help me learn a little about getting data from the web.Example of site to retrieve data:http://www.timeanddate.com/worldclock/fullscreen.html?n=136Source:expandcollapse popup<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>London, United Kingdom - current and accurate time</title> <meta name="description" content="This fullscreen or popup-window displays a clock showing current time in any time zone in the world."> <meta name="keywords" content="clock, time zone, local time, international, current, big clock, large clock, date, time, count, counts"> <link rel="stylesheet" href="http://c.tadst.com/common/wstyle.css?17" type="text/css"> <script src="http://c.tadst.com/common/fullscreen2.js" type="text/javascript"></script> <style type="text/css"><!-- a {text-decoration:none;color:#000;} .t100 {width:100%;height:100%;} .tab {margin: 0 auto;} body {overflow:hidden;} #navz {float:right;} #navz a {font-size:85%;text-decoration:none;color:#999;} img {display:block;} #wrap {position:absolute;height: 100%;} --> </style> </head> <body onload="Frst();" onresize="Frst()" onscroll="Fgt()"> <div id=navz> <a href="#" onmouseover="window.status='Increase';return true;" onmouseout="window.status=''" onclick="return Fcz(1.25)" title="Increase font size">++</a> <a href="#" onmouseover="window.status='Increase';return true;" onmouseout="window.status=''" onclick="return Fcz(1.05)" title="Increase font size (small)">+</a> <a href="#" onmouseover="window.status='Decrease';return true;" onmouseout="window.status=''" onclick="return Fcz(0.95)" title="Decrease font size (small)">-</a> <a href="#" onmouseover="window.status='Decrease';return true;" onmouseout="window.status=''" onclick="return Fcz(0.80)" title="Decrease font size">--</a> <a href="#" onmouseover="window.status='Auto';return true;" onmouseout="window.status=''" onclick="Frst()" title="Automatic font size">auto</a> <a href="#" onmouseover="window.status='Close';return true;" onmouseout="window.status=''" onclick="window.close()" title="Close window">Close</a> </div> <a href="/" target="_blank"><img src="http://c.tadst.com/gfx/mainlogo6-139.png" width=139 height=43 alt="timeanddate.com" border="0" /></a> <div id="wrap"> <table cellpadding="0" cellspacing="0" border="0" class="tab t100"><tr><td id="c1" align="center" valign="middle"> <table class=wa><tr><td class=tc> <div id=rs1><div>Local time in London</div><div id=i_date>Tuesday, March 27, 2012</div><div id=i_time>7:27:33 PM</div><div id=i_timea> <a title="British Summer Time" href="/library/abbreviations/timezones/eu/bst.html">BST</a></div></div><script type="text/javascript"> <!-- et=1333044653;function f0(d){return ld[d.getUTCDay()]+','+' '+lm[d.getUTCMonth()]+' '+d.getUTCDate()+','+' '+d.getUTCFullYear()+' at '+((d.getUTCHours()+11)%12+1)+':'+p2(d.getUTCMinutes())+':'+p2(d.getUTCSeconds())+' '+_ap(d);} function f1(d){return ld[d.getUTCDay()]+','+' '+lm[d.getUTCMonth()]+' '+d.getUTCDate()+','+' '+d.getUTCFullYear()+' at '+p2(d.getUTCHours())+':'+p2(d.getUTCMinutes())+':'+p2(d.getUTCSeconds());} function f2(d){return ld[d.getUTCDay()]+','+' '+lm[d.getUTCMonth()]+' '+d.getUTCDate()+','+' '+d.getUTCFullYear();} function f3(d){return ((d.getUTCHours()+11)%12+1)+':'+p2(d.getUTCMinutes())+':'+p2(d.getUTCSeconds())+' '+_ap(d);} cks={ctu:{t:[{t:0,o:0,a:'UTC'}],f:f1},i_date:{t:[{o:3600,a:'BST',d:1}],f:f2},i_time:{t:[{o:3600,a:'BST',d:1}],f:f3},ct:{t:[{o:3600,a:'BST',d:1}],f:f0,d:27}} lm=[];lm[2]='March';ld=[];ld[2]='Tuesday';ld[3]='Wednesday';ld[4]='Thursday'; function _ap(d){var t=Math.floor(d.getTime()/1E3)%86400;if(t===0){return 'Midnight';}if(t==43200){return 'Noon';}if(t<43200){return 'AM';}return 'PM';} idpref={i_date:1.2,i_time:5};//--> </script></td></tr></table> </td></tr></table> </div> <script src="http://c.tadst.com/common/wcommon.js?16" type="text/javascript"></script> </body> </html>I know I want to get "<div id=i_date>" and "<div id=i_time>". I think I can use objects but I'm not familiar or I don't know anything about objects. Any help, or a step by step would be appreciated. Just seeing a code to display it on a GUI would be awesome. I do know that it should be refreshed every second being that this is retrieving time. Edited March 27, 2012 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
DaleHohm Posted March 27, 2012 Share Posted March 27, 2012 Look at the examples for _IEGetObById and then use _IEPropertyGet innertext 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 Link to comment Share on other sites More sharing options...
Rogue5099 Posted March 28, 2012 Author Share Posted March 28, 2012 (edited) Thank you, #include <IE.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> GUICreate("London Time", 227, 110, -1, 1) $lRegion = GUICtrlCreateLabel("", 1, 1, 227, 24, $SS_CENTER) $lDate = GUICtrlCreateLabel("", 1, 30, 227, 24, $SS_CENTER) GUICtrlSetFont(-1, 12) $lTime = GUICtrlCreateLabel("", 1, 60, 227, 52, $SS_CENTER) GUICtrlSetFont(-1, 32, 600) GUISetState(@SW_SHOW) Global $oIE = _IECreate ("http://www.timeanddate.com/worldclock/fullscreen.html?n=136", 0, 0) $oDiv = _IEGetObjById ($oIE, "rs1") GUICtrlSetData($lRegion, _IEPropertyGet($oDiv, "innertext")) Data() AdlibRegister("Data", 1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _IEQuit($oIE) Exit EndSwitch WEnd Func Data() $oDiv = _IEGetObjById ($oIE, "i_date") GUICtrlSetData($lDate, _IEPropertyGet($oDiv, "innertext")) $oDiv = _IEGetObjById ($oIE, "i_time") GUICtrlSetData($lTime, _IEPropertyGet($oDiv, "innertext")) EndFunc Edited March 28, 2012 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Cuthbert Posted April 3, 2012 Share Posted April 3, 2012 Maybe I am misunderstanding what is actually being looked for, but wouldn't it be quicker to just view all the hidden source code with Opera and the Inspect Element command when you right-click the page? If you just wanted to see the code itself... Link to comment Share on other sites More sharing options...
kylomas Posted April 3, 2012 Share Posted April 3, 2012 Cuthbert, He wants to get a text value programmatically, a very common event... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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