Chris Redford
Chris Redford

Reputation: 17778

Determine current Mac Chrome web page using Python

Is there a way to determine programmatically, using Python, which web page is currently active in Google Chrome?

Upvotes: 1

Views: 550

Answers (2)

Neffster
Neffster

Reputation: 136

Google Chrome for Mac has added the AppleScripting method for getting the URL.

Here's the Chromium AppleScript SDK

https://sites.google.com/a/chromium.org/dev/developers/design-documents/applescript

Example from the page linked below:

tell application "Google Chrome"
   get URL of active tab of window 1
end tell

More examples here:

http://laclefyoshi.blogspot.com/2010/10/google-chrome-ver.html

Upvotes: 2

Alex Martelli
Alex Martelli

Reputation: 881635

Not yet, it seems. Such tasks are done, with other browsers, via the Applescript interface, but, as this thread shows, while hotly requested for Chrome on the Mac this feature is not there yet.

(Once a Mac app does get a good Applescript interface, there are several ways to use that interface from Python, without needing to actually involve Applescript as a language -- this has been touched upon on other SO questions about other apps -- but the problem is that Chrome in particular doesn't yet support this quintessentially Mac-ish functionality).

Given the insistence of the request I'd expect somebody to eventually roll up their sleeves and contribute a patch for the purpose, but it doesn't seem to have occurred yet.

Upvotes: 0

Related Questions