Waiting until a URL appears

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
zopita
Newbie
Posts: 19
Joined: Wed Feb 18, 2009 5:45 pm
Location: Spain

Waiting until a URL appears

Post by zopita » Thu Jun 23, 2011 2:20 pm

Hi,

In a web page my macro press the button for go to the nex page.

I need my macro waits until URL bar= http://www.xxxxxxxxxx.yyyyyy

I try use "WaitScreenText>URL name" but mission imposible for me :(. Do you help me, please?

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 23, 2011 2:25 pm

What method are you using to control your browser. If you use WebRecorder or VBScript to control IE you are able to wait for the page to finish loading (which is better than just waiting for the URL bar to show the URL - the page will still be loading).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

zopita
Newbie
Posts: 19
Joined: Wed Feb 18, 2009 5:45 pm
Location: Spain

Post by zopita » Thu Jun 23, 2011 3:06 pm

Marcus,

Browser Control: prehistoric system :oops:

I am sorry to write so much but it is very difficult to explain in English. Thanks for your patience.

I start on this website: http://cvc.cervantes.es/foros/foro_esp.

The manual process is as follows:
Save this page as 1.txt
Press the right arrow and jump to page 2
Wait page 2 loads
Save page as 2.txt

And so on.

The link is the right arrow is Javascript: ir_pagina ('next') so I created a Word table with two columns:

..............................URL to paste into Mozilla............ Save this page as:
for page 2:............javascript: ir_pagina ('next') ................. 2.txt
for page 3:............javascript: ir_pagina ('next') ................. 3.txt
for page 4:............javascript: ir_pagina ('next') ................. 4.txt

The macro starts Word and do this:
Copy javascript: ir_pagina ('next')
Jump to Mozilla
Paste javascript: ir_pagina ('next') in URL bar
Press Enter
Wait loading page 2
Save as ...
Jump to Word and copied to the clipboard 2.txt
Jump to Mozilla and paste 2.txt in the Save As window
Jump to Word and repeat the process.

Thanks, Marcus!
____________________________________________________


// C:\Documents and Settings\Administrador\Mis documentos\Macro Scheduler 11\estadisticas frias 1.scp
// Recorded on jueves, junio 23, 2011, at 03:23 PM

//Recorded Events
Let>WW_TIMEOUT=5
CapsOff

Wait>1.84


//en Word, corta el nombre del script
Press CTRL
Wait>0.1
Send>x
Wait>0.1
Release CTRL
Wait>0.1

//salta a CVC
Press ALT
Wait>0.1
Press Tab
Wait>0.1
Release ALT
WaitWindowOpen>CVC. Foros. Resultados de la búsqueda. - Mozilla Firefox
Wait>0.1

//barra direcciones y pega el javascript
Press ALT
Wait>0.1
Send>d
Wait>0.1
Release ALT
Wait>0.1
Press CTRL
Wait>0.1
Send>v
Wait>0.1
Release CTRL
Wait>0.1
Press Enter
Wait>0.1

//espera el salto de página

//WaitRectChanged>5,550,40,735,100,100
//Wait>150


WaitScreenText>http://cvc.cervantes.es/foros/resultados.asp
MessageModal>supongo que es la pag siguiente
Wait>10



//cuando ha saltado la página, guarda como...
Press ALT
Wait>0.1
Send>a
Wait>0.1
Release ALT
Wait>0.1
Send>a
WaitWindowOpen>Guardar como

Wait>0.1
//salta a word para cortar nombre archivo
Press ALT
Wait>0.01
Press Tab
Wait>0.1
Release ALT
WaitWindowOpen>numeración.doc - Microsoft Word

Wait>0.1
Press Tab
Wait>0.1
Press CTRL
Wait>0.1
Send>x
Wait>0.1
Release CTRL
Wait>0.1
//salta al guardar como y pega nombre de archivo
Press ALT
Wait>0.1
Press Tab
Wait>0.1
Release ALT
WaitWindowOpen>Guardar como

Wait>0.1
Press CTRL
Wait>0.1
Send>v
Wait>0.1
Release CTRL
Wait>0.1
Press Enter
WaitWindowOpen>CVC. Foros. Resultados de la búsqueda. - Mozilla Firefox

Wait>0.1
//salto a word y tabulador al siguiente nombre de script
Press ALT
Wait>0.1
Press Tab
Wait>0.1
Release ALT
WaitWindowOpen>numeración.doc - Microsoft Word
MoveWindow>numeración.doc - Microsoft Word,-4,-4
ResizeWindow>numeración.doc - Microsoft Word,1032,746
Wait>0.1
Press Tab
Wait>0.1
Press CTRL

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 23, 2011 3:39 pm

That seems a bit cumbersome. This does it all in the background:

Code: Select all

Let>output_folder=c:\temp\
Let>WLN_NOCRLF=1

//start page
Let>page=1

//do page 1
GoSub>GetAndSavePage

//find out how many pages there are
Let>pattern=(?<=<NOBR>Página: <b>1</b> de <b>)\d(?=</b></NOBR>)
RegEx>pattern,html,0,matches,nm,0
Let>num_pages=matches_1

//Do rest of pages
Repeat>page
    Let>page=page+1
    GoSub>GetAndSavePage
Until>page=num_pages

SRT>GetAndSavePage
  Let>url=http://cvc.cervantes.es/foros/default.asp?vForo=11&Mensajes_PagingMove=%page%&vOrden=1
  HTTPRequest>URL,,GET,,html
  IfFileExists>%output_folder%%page%.txt
    DeleteFile>%output_folder%%page%.txt
  Endif
  WriteLn>%output_folder%%page%.txt,wr,html
END>GetAndSavePage
No browser windows, no key sends. It gets the first page, determines how many pages there are by looking at the source with regex and then loops through for all subsequent pages just changing the appropriate parameter for the page number.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

zopita
Newbie
Posts: 19
Joined: Wed Feb 18, 2009 5:45 pm
Location: Spain

Post by zopita » Fri Jun 24, 2011 10:55 am

You were very friendly.

I could understand the use of variables. I have to adjust your macro to other forums and website form results but I'll get it myself, I'm sure.

Thank you, Marcus. :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts