| View previous topic :: View next topic |
| Author |
Message |
ls78
Joined: 03 May 2006 Posts: 44
|
Posted: Thu Jul 10, 2008 8:24 pm Post subject: A challenge , solved weekly speed camera info from website |
|
|
i want to make a script that will return a few lines of text from a website on where the mobile speed camera are located every week . as there is no rss feed for this . i just want a gui on my desktop showing the information without having to load the whole page.
ok any ideas , am i asking too much from autohotkey ?
ok , what i want to do is make a gui that loads some text from a website
any ideas would be great .
thanks for reading.
luke
Last edited by ls78 on Fri Jul 11, 2008 3:41 pm; edited 1 time in total |
|
| Back to top |
|
 |
ArchCarrier
Joined: 03 Jun 2008 Posts: 27
|
Posted: Thu Jul 10, 2008 8:28 pm Post subject: |
|
|
| I have no idea how to do this with AHK, but this site lets you create RSS feeds for websites that don't offer feeds. |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Thu Jul 10, 2008 8:30 pm Post subject: |
|
|
| You could UrlDownloadToFile the web page, then, assuming there is some sort of identifier around the info you are looking for, pull the text from the file with a RegExMatch or something? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Fri Jul 11, 2008 12:35 am Post subject: |
|
|
it would help if you can tell us the website or a similar one. _________________
(Common Answers) |
|
| Back to top |
|
 |
ls78
Joined: 03 May 2006 Posts: 44
|
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Fri Jul 11, 2008 3:14 pm Post subject: |
|
|
1. Do a View Source of the webpage
2. Search your target text in the source
| Code: | <p class="MsoNormal" style="MARGIN: 0pt"><a name="OLE_LINK4"></a><a name="OLE_LINK3"></a><a name="OLE_LINK1"><span style="mso-bookmark: OLE_LINK3"><span style="mso-bookmark: OLE_LINK4"><font face="Arial" size="3"><span style="FONT-SIZE: 12pt; FONT-FAMILY: Arial">A303; A36, M4, A419, A338, A346, A30, A354, A342, A360, A350, B390, A429, B4040, Swindon and Trowbridge areas.</span></font></span></span></a></p>
<span style="mso-bookmark: OLE_LINK4"></span><span style="mso-bookmark: OLE_LINK3"></span><span style="mso-bookmark: OLE_LINK1"></span>
<p class="MsoNormal" style="MARGIN: 0pt; TEXT-ALIGN: center" align="center"><font face="Arial" size="3"><span style="FONT-SIZE: 12pt; FONT-FAMILY: Arial"> </span></font></p>
|
3. Find the smallest unique html before and after your target, then use something like this:
| Code: | ; BEWARE! Both RegEx and AHK need certain escape sequences!
;
; http://www.autohotkey.com/docs/commands/_EscapeChar.htm
; http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm
;
before := "4""><font face=""Arial"" size=""3""><span style=""FONT-SIZE: 12pt; FONT-FAMILY: Arial"">"
after := "<"
; "(.*)" is regex for: return anything in match variable as array
pattern := before . "(.*)" . after
URLDownloadToFile, http://www.safetycameraswiltshire.co.uk/mobile.asp, %A_ScriptDir%\html.tmp
FileRead, aFile, %A_ScriptDir%\html.tmp
RegExMatch(aFile, pattern, match)
MsgBox % match1 |
disclaimer: not tested, but should work
HTH |
|
| Back to top |
|
 |
ls78
Joined: 03 May 2006 Posts: 44
|
Posted: Fri Jul 11, 2008 3:39 pm Post subject: cheers |
|
|
hey n-l-i-d well done !
works a treat . than you very much , very nice and easy instructions ,
cheers
luke . |
|
| Back to top |
|
 |
Wouther
Joined: 01 May 2007 Posts: 83 Location: The Netherlands
|
Posted: Fri Jul 11, 2008 4:03 pm Post subject: |
|
|
| n-l-i-d wrote: | | Code: | | ; BEWARE! Both RegEx and AHK need certain escape sequences! |
| To prevent having to escape and thus easier changable in the future, you can use this: (not tested)
| Code: | | pattern := "\Q" . before . "\E(.*)\Q" . after . "\E" |
_________________ Printing css/html-formatted text |
|
| Back to top |
|
 |
|