barak manos barak manos - 1 year ago 116
Python Question

Python: How to access a YouTube web page?

I am opening a YouTube web page using the 'webbrowser' module:

controller = webbrowser.get()"")

The video begins to play, and I would like my Python application to resume as soon as the video ends or the browser is closed.

Now, I cannot use
for that, because it will force me to wait until the song is over (the app will not continue if I "fast-forward" the video, or if I simply close the browser).

So I basically need to get some indication from the web page, regarding the status of the video, and another indication in case the web page is suddenly closed.

Can I use the handle I have created using
, in order to do that?


Answer Source

You can't at all. The webbrowser module hands it over to a browser over which it has no control whatsoever.

You'd need to host your own browser control through something like QtWebkit in PySide or an equivalent in pygtk/wxPython. Then you could interact with it as you would own it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download