1

I want to write a Chrome extension which gets the page source and I have found some references (1, 2) on how to do it. However, the end code that would be using this source is in Python. Is there any way I could write Chrome extension and call its methods in Python?

Note: I have tried using Selenium to get browser's source. However, I'm stuck when the page doesn't stop loading. There is a bug in selenium which prevents it from doing anything if the page doesn't stop loading. The browser doesn't return back to Selenium so I'm trying alternate methods.

Community
  • 1
  • 1
TheRookierLearner
  • 3,643
  • 8
  • 35
  • 53
  • What exactly is your chrome extension doing, and why do you need to pass it to Python? Depending on what you want, it may be possible to do entirely in Python, especially if you just want the page source code – Parker Oct 19 '14 at 20:01
  • Check: http://stackoverflow.com/questions/16886908/guidance-for-building-a-google-chrome-extension-in-python – user3378649 Oct 19 '14 at 20:02
  • @Parker - I haven't written the Chrome extension yet. I want to write it in a way that whenever the extensions method is called (using the Python code), it will get the page source and hand it to the Python code. I want something to replace the `page_source` property of Selenium. – TheRookierLearner Oct 19 '14 at 20:08
  • Don't think that's possible unless you want to alter and compile Chromium yourself ;). Would you be okay with a pure python solution that returns the source of a given URL? – Parker Oct 19 '14 at 20:09
  • Everything's fine as long as I get the source of the current page loaded in the browser (along with all the extra elements that any extension adds in the web page) – TheRookierLearner Oct 19 '14 at 20:12
  • It is possible to make Chrome start a process and communicate with it over standard I/O. If you can live with that (i.e. make that process a daemon that your main program will query) it's achievable. – Xan Oct 19 '14 at 20:59

0 Answers0