Sign in to follow this  
Followers 0
gseller

Google Anywhere World Time

9 posts in this topic

I am trying to make a word clock like the international clock SmOke_N & Valuater made using _InetGetSource and StringRegExp but can;t make it work. Here is thge latest code I am trying:

#include <INet.au3>

$case = '(?i)'

$read = ConsoleWrite(_INetGetSource('http://www.google.com/search?hl=en&q=time+tulsa'))

$time = StringRegExp ( $read, $case & '<alt="Clock"></td><td valign="middle"></td>', 4)

MsgBox(0,"International Clock","The Current Time In " & $time )oÝ÷ ØÛh©jx§µêÚrدz)éºÜ"¶®]£ ðêÞÊjznWhÂv¢fèjw,yªky×wr§¶¼¨­È­ÊíÊ¢*.®'r+rýÊ.Úòjwbë`zÛ(º»{¥Ç§uúèØ^znµ©Ýi×m¢Ø^º¹méàzÛaz)ߢ¹¶*'jwky§bµúèØ^ çb½©Ý+ÞæÚrKazئz)ÞØ^­©¬º1¢¶¥Ëoìz·¢²Ø^ çb¼¦¶¼¢h­æjëh×6<div id="res">
 <p class="e"></p>
 <table border="0" cellpadding="0" cellspacing="0">
  <tr>
   <td width="47" valign="top">
   <img border="0" width="40" height="30" valign="middle" src="[url="http://www.google.com/chart?chs=40x30&chc=localtime&cht=cf&chd=s:Sd&sig=z2XuwGilwETpVX4bI8TVovXa8eU"]http://www.google.com/chart?chs=40x30&chc=localtime&cht=cf&chd=s:Sd&sig=z2XuwGilwETpVX4bI8TVovXa8eU[/url]" alt="Clock"></td>
   <td valign="middle"><b>6:29 PM</b> Sunday (CDT) - <b>Time</b> in <b>
   Tulsa</b>, Oklahoma</td>
  </tr>
 </table>
 <div>

Can someone help me get this going? I have had code with inputs and all, just trying to make it read the time and date info from google right now.

Thank You in advance...

Share this post


Link to post
Share on other sites



I know and it is brilliant but I can't seem to make it work for my project, I have been working on this for a couple weeks now and seen your time updater and was excited to try it and it looks like it is just what I need in that one function. I just can't make it work so I decided to ask for help. It was your script that helped me where I got so far, I scrapped it just before putting the code on here.

Share this post


Link to post
Share on other sites

I'm a sucker for StringRegExp() <_< Smoke is the expert.

I can see one big mistake in your code though.. ConsoleWrite() does not return whatever you are writing. It doesn't return anything.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes, it is pretty cool stuff from what I have seen. I want to know more about it, Here is some other code I am trying but I only get the return from using you function from the time update. It is cool bu I am not sure if I am not getting my StringRegExp pattern right or not reading something right. Any ideas?

#include <GUIConstants.au3>
#include <inet.au3>


GuiCreate("Google Anywhere Clock", 350, 200, -1, -1)
$font       = "Arial Bold"
$SearchCity = GuiCtrlCreateButton("Search", 265, 11, 80, 20, $BS_DEFPUSHBUTTON)
$Input = GuiCtrlCreateInput("tulsa", 100, 11, 160, 20)
$Input1 = GUICtrlCreateEdit("", 12, 65, 330, 125,BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$WS_VSCROLL))

$SearchLabel = GuiCtrlCreateLabel("Time Search", 12, 13, 88, 30)
GUICtrlSetFont(-1, 9, 400, 0, $font)
GUICtrlSetColor($SearchLabel, 0xff0000)
GuiCtrlCreateGroup("", 2, 0, 346, 40)
GuiSetState()

$Group1 = GUICtrlCreateGroup("Search Results", 2, 45, 346, 175)

GUICtrlCreateGroup("", 05, 20, 1, 1)
$r = GUICtrlRead($Input1)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $SearchCity
    _GoogleTime()
    EndSelect
WEnd

Func _GoogleTime()
    Local $aSRE = StringRegExp( _
        _INetGetSource("http://www.google.com/search?hl=en&q=time+" & $Input), _
        '<\id="res"\>\<\alt="Clock"\>\</td\>\<td valign="middle"\>(.*?)\<', 3)
        GUICtrlSetData($Input1, $aSRE)
        ;MsgBox(0, "Your Intl Clock Reult", $aSRE)
    If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
    Local $aINF = StringRegExp($aSRE[0], "(?i)(\w+), (\w+) (\d+), (\d+).*? (\d+):(\d+):(\d+) (\w+)",3)
    If IsArray($aINF) = 0 Then Return SetError(2, 0, 0)
    If UBound($aINF) <> 8 Then Return SetError(3, 0, 0)
    Return $aINF
    EndFunc;==>_GoogleTime()

edit: typo...

Edited by gesller

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yay I did it <_<

#include <Inet.au3>
MsgBox(0,"",_GoogleTime("buenos aires"))
Func _GoogleTime($sCity)
    $sSource=_INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity)
    $aSRE=StringRegExp($sSource,'<(?i)td valign=middle><(?i)b>(.*?)<(?i)/b>',1)
    If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
    Return $aSRE[0]
 EndFunc;==>_GoogleTime()

I should totally learn how to use StringRegExp properly :">

Oh, and don't give me credit for that function, Smoke did the whole thing.

#include <GUIConstants.au3>
#include <inet.au3>


GuiCreate("Google Anywhere Clock", 350, 200, -1, -1)
$font      = "Arial Bold"
$SearchCity = GuiCtrlCreateButton("Search", 265, 11, 80, 20, $BS_DEFPUSHBUTTON)
$Input = GuiCtrlCreateInput("tulsa", 100, 11, 160, 20)
$Input1 = GUICtrlCreateEdit("", 12, 65, 330, 125,BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$WS_VSCROLL))

$SearchLabel = GuiCtrlCreateLabel("Time Search", 12, 13, 88, 30)
GUICtrlSetFont(-1, 9, 400, 0, $font)
GUICtrlSetColor($SearchLabel, 0xff0000)
GuiCtrlCreateGroup("", 2, 0, 346, 40)
GuiSetState()

$Group1 = GUICtrlCreateGroup("Search Results", 2, 45, 346, 175)

GUICtrlCreateGroup("", 05, 20, 1, 1)
$r = GUICtrlRead($Input1)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $SearchCity
        $city=GUICtrlRead($Input)
    GUICtrlSetData($Input1,_GoogleTime($city))
    EndSelect
WEnd

Func _GoogleTime($sCity)
    $sSource=_INetGetSource("http://www.google.com/search?hl=en&q=time+" & $sCity)
    $aSRE=StringRegExp($sSource,'<(?i)td valign=middle><(?i)b>(.*?)<(?i)/b>',1)
    If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
    Return $aSRE[0]
 EndFunc;==>_GoogleTime()
Edited by Nahuel

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sweet!! That Rocks!! You are my hero for the day.. LOL Thanks!

edit: Well, I thank you both! I have been pulling my hair out trying to make this work.

Edited by gesller

Share this post


Link to post
Share on other sites

Your worldclock is way cool also, embeding the website is cool, have you tried google worldtime? I like it because there are less limitations on what cities/countries you can search. The only drawbacks now are when a contry or city has multiple timezones it breaks the reg expression. I am sure it can be corrected, maybe in time.. <_< Thanks...

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