Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.
from selenium import webdriver driver = webdriver.Chrome()
driver.get(‘https://www.bing.com/‘)
res = driver.execute_cdp_cmd(‘Page.captureSnapshot‘, {})
with open(‘q.mhtml‘, ‘w‘) as f: f.write(res[‘data‘]) driver.quit()
------------
Is it(like .execute_cdp_cmd) possible to be used in cef4?
marks my learning notes
1.when we click saveasmhtml, run Chromium1.ExecuteDevToolsMethod. (see the SaveasMHTML1Click procedure.)
2.after executing, OnDevToolsMethodResult of Chromium1 will be trigered, and we send PostMessage named MINIBROWSER_DTDATA_AVLBL and data was stored with FDevToolsMsgValue. see procedure TMiniBrowserFrm.Chromium1DevToolsMethodResult.
3.deal with MINIBROWSER_DTDATA_AVLBL Message. In this procedure to save file. see procedure DevToolsDataAvailableMsg(var aMessage : TMessage); message MINIBROWSER_DTDATA_AVLBL
4.definition(all global):
1)We must define FDevToolsMsgValue to store result when result data was available(TMiniBrowserFrm.Chromium1DevToolsMethodResult) and used in the DevToolsDataAvailableMsg procedure.
2)we must know DevToolsMsgID to operate correspond command. So we must define MsgIDs FDevToolsMsgID and FMHTMLMsgID.
FormCreate, set FDevToolsMsgID := 0;
when clicking save mhtml menu: inc(FDevToolsMsgID); set FMHTMLMsgID := FDevToolsMsgID.
5.another:
screenshot,only replace FMHTMLMsgID with FScreenshotMsgID