views:

56

answers:

2

Hello, currently im making some crawler script,
one of problem is sometimes if i open webpage with PAMIE,webpage can't open and hang forever.
are there any method to close PAMIE's IE or win32com's IE ?
such like if webpage didn't response or loading complete less than 10sec or so .
thanks in advance

A: 

I think what you are looking for is somewhere to set the timeout on your request. I would suggest looking into the documentation on PAMIE.

adamse
thanks for your answer ^^
paul
+1  A: 

Just use, to initialize your PAMIE instance, PAMIE(timeOut=100) or whatever. The units of measure for timeOut are "tenths of a second" (!); the default is 3000 (300 seconds, i.e., 5 minutes); with 300 as I suggested, you'd time out after 10 seconds as you request.

(You can pass the timeOut= parameter even when you're initializing with a URL, but in that case the timeout will only be active after the initial navigation).

Alex Martelli
hello, sorry for late reply ..your method is working very well .thanks !i was add follow timeout option, and working well.iepa = PAMIE(timeOut=100)iepa.Visible = 1 if some eorror encounter,can i add some error handling code?when encounter error i want to go "def main():" for example..you can some advice such like code for me?thanks in advance!
paul
@paul, the error will raise an exception (don't know which off-hand, and the docs are scanty, but can't you just look in the source?) and you can handle it with try/except (which you can place in `main` if you wish -- the exception will propagate up the chain of callers until it meets a suitable except clause).
Alex Martelli
thanks a lot Paul :)
paul