iiseymour / chromote Goto Github PK
View Code? Open in Web Editor NEWSimple wrapper to drive Google Chrome from Python
License: MIT License
Simple wrapper to drive Google Chrome from Python
License: MIT License
Hi, thanks for your job!
By using chromote, i can set a url to remote Chrome(in docker container) and return a html code, but i can't sent a post request to the chrome, do you have any idea? Thanks again!
example: How can i get a logged-in page when i send a login url to remote headless Chrome?
This is perhaps more of a question than an issue, but in my project, I need to add "returnByValue": False
, at around line 72 in __init__.py
:
(note, I'm adding line breaks only to make it easier to read)
def evaluate(self, javascript):
"""
Evaluate JavaScript on the page
"""
return self._send(
{"method": "Runtime.evaluate",
"params": {"expression": javascript,
"returnByValue": False}}) # <---- This bit
Without this, I don't get back the full string contents of returned data, e.g. the results of Array maps and so on. I'm happy to make a PR to make this a setting (e.g. an extra param on evaluate
, with default set to True
), but just wanted to find out your thoughts?
Hey, thanks for making this repo. I tried to run but I'm running into an issue:
>>> from chromote import Chromote
>>> chrome = Chromote()
>>> chrome
Chromote(host="localhost", port=9222)
>>> print chrome
According to readme, I should see the following:
[Chromote(tabs=1)]
But instead, I see this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 156, in __str__
return '[Chromote(tabs=%d)]' % len(self)
File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 153, in __len__
return len(self.tabs)
File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 150, in tabs
return tuple(self._get_tabs())
File "/usr/local/lib/python3.6/site-packages/chromote/__init__.py", line 132, in _get_tabs
for tab in res.json():
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 886, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Tried this in python 2.7 and got the same result as well.
Any ideas????
Thanks!
Could you please add a new version number to the current code? Currently, pip install chromote
installs version 0.3.0, which is missing the add_tab, close_tab
functionality implemented in commit #13.
First of all, thanks for a nice software!
Could you add LICENSE file?
The following page might help for choosing a license.
Choosing an open source license doesn’t need to be scary - Choose a License
Thanks!
Hi, sometimes this exception is yield:
Traceback (most recent call last):
File "D:\sources\personal\www\www.todotrucos.info\posts\foo_post.py", line 33, in <module>
wpp.run(filename=__file__, post_content=POST, tags=[], post_status="draft")
File "D:\sources\personal\python\framework\web\wp_lib.py", line 280, in run
print chrome.tabs
File "d:\virtual_envs\py2710\lib\site-packages\chromote\__init__.py", line 122, in tabs
return tuple(self._get_tabs())
File "d:\virtual_envs\py2710\lib\site-packages\chromote\__init__.py", line 106, in _get_tabs
yield ChromeTab(tab['title'], tab['url'], tab['webSocketDebuggerUrl'])
KeyError: 'webSocketDebuggerUrl'
And the code yielding that exception is very basic
chrome = Chromote()
print chrome.tabs
As i said, it happens sometimes but i don't know, any clue why?
Regards
from chromote import Chromote
chrome = Chromote()
chrome.tabs[0].set_url('http://www.nytimes.com')
print(chrome.tabs[0])
"The New York Times - Breaking News, World News & Multimedia - https://www.nytimes.com/"
How we we get the contents of the page?
I couldn't get Chrome to start with the remote debugging port enabled. I finally realized that you have to kill any chrome processes on Windows first, before you can start Chrome with the remote debugging port enabled. I thought others may benefit from this info.
Is the full documentation available anywhere for the API?
I am looking for a way to open multiple tabs and cycle between them, preferably without reloading the tab each time.
Is it possible to use Chromote for multiple Chrome processes with different debugger ports? For example, if I open two new Chrome windows with debugger port 9222 and port 9223, can I create two Chromote instances in a single parent process and connect them to their respective browser processes?
The reason for this is that I want to use Chromote as a load testing tool for a web application, where a number of clients open up browsers and remote control them simultaneously.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.