Last active
November 23, 2017 09:04
-
-
Save famasya/f13896e7113ab82a0d60b9dbb9330a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import websocket, requests | |
def main(): | |
url = "http://localhost:9222/json" | |
# Get DebuggerURL | |
connection = requests.get(url) | |
# Initiate websocket connection via debugger URL | |
ws = websocket.create_connection(connection.json()[0]['webSocketDebuggerUrl']) | |
ws.send( | |
json.dumps({ | |
"id":0, | |
"method": "Runtime.evaluate", | |
"params": { | |
"expression": "location.href" | |
} | |
}) | |
) | |
result = json.loads(ws.recv()).get("result") | |
print(result) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment