Refreshing of urllib.urlopen()

  • Thread starter Michael Gruenstaeudl
  • Start date
M

Michael Gruenstaeudl

Hi,
I am fairly new to Python and need advice on the urllib.urlopen()
function. The website I am trying to open automatically refreshes
after 5 seconds and remains stable thereafter. With
urllib.urlopen().read() I can only read the initial but not the
refreshed page. How can I access the refreshed page via
urlopen().read()? I have already tried to intermediate with
time.sleep() before invoking .read() (see below), but this does not
work.

page=urllib.urlopen(url)
time.sleep(20)
htmltext=page.readlines()

Thanks,
Michael G.
 
N

Nobody

I am fairly new to Python and need advice on the urllib.urlopen()
function. The website I am trying to open automatically refreshes
after 5 seconds and remains stable thereafter. With
urllib.urlopen().read() I can only read the initial but not the
refreshed page. How can I access the refreshed page via
urlopen().read()? I have already tried to intermediate with
time.sleep() before invoking .read() (see below), but this does not
work.

In all probability, the server is instructing the browser to load a
different URL via either a Refresh: header or a <meta http-equiv="refresh">
tag in the page. You will have to retrieve that information then issue a
request for the new URL.

It might even be redirecting via JavaScript, in which case, you lose (it's
possible to handle this case, but it's difficult).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top