Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6189097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:20:56+00:00 2026-05-24T02:20:56+00:00

I want to use the remote socket debugging stuff for Chrome devtools ( link

  • 0

I want to use the remote socket debugging stuff for Chrome devtools (link) from Python.
I’m using code adapted from here.

I’ve managed to get ping and list_tabs working. But I can’t figure out how to evaluate_javascript. Can anybody tell me what I’m doing wrong?

import subprocess
import time, json, socket

from jca.files import my_paths

def request(tool, destination=None, **kw):
  # Send a command via socket to 'DevToolsService' or 'V8Debugger'
  j = json.dumps(kw)
  request = 'Content-Length:%d\r\nTool:%s\r\n' % (len(j), tool)
  if destination:
    request += 'Destination:%s\r\n' % (destination,)
  request += '\r\n%s\r\n' % (j,)
  sock.send(request)
  if kw.get('command', '') not in RESPONSELESS_COMMANDS:
    time.sleep(.1)
    response = sock.recv(30000)
    if response.strip():
      j = response.split('\r\n\r\n', 1)[1]
      return json.loads(j)

if __name__ == '__main__':
  proc = subprocess.Popen('"%s" --remote-shell-port=9222' % my_paths.chrome_exe)
  RESPONSELESS_COMMANDS = ['evaluate_javascript']
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect(('localhost', 9222))
  sock.send('ChromeDevToolsHandshake\r\n')
  result = sock.recv(1024)
  print 'ping: ', request('DevToolsService', command='ping')
  time.sleep(4)
  print 'list_tabs: ', request('DevToolsService', command='list_tabs')
  request('V8Debugger', command='evaluate_javascript', 
          data='javascript:window.location.reload()')
  sock.close()
  print 'done'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:20:57+00:00Added an answer on May 24, 2026 at 2:20 am

    The problem was that I didn’t set a tab_id for destination. Adding destination=2 to the request call fixes the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use remote debugging. The program that I want to debug runs
The use case I want to achive is. 1. Fetch XML from a remote
I want to remote slide PowerPoint use socket C# like: next/previous slide and go
I want to use curl to get a stream from a remote server, and
I want to use SOLR's remote-streaming facility to extract and index the content of
I want to use git as a local repository against a remote SVN repository.
I want to use the Publish.GacRemove function to remove an assembly from GAC. However,
i want use some data from a website with web service. i have a
I want to make a CListView that will read his rows from e remote
I want to use Spring Batch and Spring Integration to import data from database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.