Jump to content


Photo

How to copy text presented on a web page, not in the HTML?


  • Please log in to reply
4 replies to this topic

#1 merc1

merc1
  • Members
  • 2 posts

Posted 29 June 2012 - 10:38 AM

I'm using this program to find as small piece of text that is on the webpage most of the time. As soon as the text is no longer there the alarm goes of, as that means that there are some new search results on the page for me...

But now they changed the page using ASP, so I can no longer detect the text string in the HTML-code. So instead of copying the html-code, I want to copy the text displayed on the webpage so I can search that instead. But how do I do that? How can I change the code so that the alarm goes of when the text "Just nu" is NOT on the page?

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

lookfor=just nu   ; The exact phrase is "Just nu" so maybe there is case sensitivity as well...
times=0

loop
{


loop
{
sleep, 1000
UrlDownloadToFile, http://www.stenafastigheter.se/sok-fastigheter/lediga-bostader/Sidor/default.aspx?ort=Stockholm, tmp.txt
FileRead, text, tmp.txt
stringgetpos, pos, text, %lookfor%
if (pos=-1)
break
}

soundplay, alarm.wav, wait
if (times=0)
{
run,http://www.stenafastigheter.se/sok-fastigheter/lediga-bostader/Sidor/default.aspx?ort=Stockholm
times=1
} 


}

Any input how to get this to work is appreciated.

/merc1

#2 Guests

  • Guests

Posted 29 June 2012 - 11:05 AM

Use COM <!-- m -->http://www.autohotke... ... automation<!-- m -->

#3 merc1

merc1
  • Members
  • 2 posts

Posted 29 June 2012 - 11:25 AM

Use COM <!-- m -->http://www.autohotke... ... automation<!-- m -->

Thanks, but that is a bit to advanced for me at the moment. I'm a noob at AHK, so using COM is still beyond my ability. Any hands on help with the coding wold be great.

#4 ErrorOnLine1

ErrorOnLine1
  • Guests

Posted 29 June 2012 - 10:01 PM

Something like this?
needle = Just nu
Send, a ;select all text on the page
Send, ^c, ;copy
FileAppend, %clipboard%`r`n, yourpath\yourfile
FileRead, haystack, yourpath\yourfile
IfInString, haystack, %needle%


#5 hd0202

hd0202
  • Members
  • 454 posts

Posted 30 June 2012 - 01:18 PM

.. so using COM is still beyond my ability.

This uses COM and needs AutoHotkey_L :!:
But this code will never get any award in any beauty contest :lol:
loc = Lomma,Stockholm,Lund,Uppsala
stringsplit, l, loc, `,
loop, % l0
{
IE := IE_Run("http://www.stenafastigheter.se/sok-fastigheter/lediga-bostader/Sidor/default.aspx?ort=" l%a_index%)
; Msgbox % IE.HWND "`n" IE.LocationURL
sleep, 10000  ; is extra long
click, 500, 500  ; [color=#0000FF]may vary depend on the toolbox lines in the header[/color]
clipboard =
send ^a
sleep, 500
send ^c
clipwait, 5
ifinstring, clipboard, Just nu
  out .= l%a_index% " = Just nu `n"
ie.quit
}
msgbox, % out
exitapp

IE_Run(URL, V="True") {
   IE := ComObjCreate("InternetExplorer.Application")
   IE.Visible := V
   IE.Navigate(URL)
While( !InStr(rs, 4)) ;  || StrLen(rs)<7000 )
{
  rs.= IE.ReadyState
  Sleep 500
}
Return IE
}
The CLICK must go into the area with the search string respectively with the pictures.

I hope someone can give better code.

Hubert