I am trying to get the dates when available on this datepicker
When availables , the dates are saved in the variable available_dates inside a js script which fills the html input.
HTML of the input :
<input type="text" readonly="" class="form-control-input app_date validate" style="width: 260px;" id="app_date" name="app_date" placeholder="YYYY-MM-DD" onchange="this.form.submit();showLoader();" value="" autocomplete="off">
How can i retrieve the values from available_dates when the dates are availables, get them to my python script to select one of them.
The following python script didn't work :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
driver.find_element(By.XPATH, "//*[#id='app_date']").click()
time.sleep(3)
try:
print([date.get_attribute("innerHTML") for date in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[#class='datepicker-days']/table[#class=' table-condensed']//tr//td[#class='day activeClass' and #title='Book']")))])
except TimeoutException:
print("No booking dates available for the current month")
driver.refresh()
JS script :
<script type="text/javascript" xpath="1">
var today = new Date();
var dd = today.getDate()+1;
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = yyyy+'-'+mm+'-'+dd;
function formatDate(rawDate) {
var day = ("0" + rawDate.getDate()).slice(-2);
var month = ("0" + (rawDate.getMonth() + 1)).slice(-2);
return (day)+ "-" + (month)+ "-" +rawDate.getFullYear() ;
}
$(document).ready(function() {
var dt1 = '2023-02-14';
var checkService = 'Normal';
$('.date_of_birth').datepicker({
format: "yyyy-mm-dd",
endDate: new Date(dt1),
startDate: '-100y',
autoclose: true,
startView: 2
});
$('.pptIssueDate').datepicker({
format: "yyyy-mm-dd",
endDate: new Date(dt1),
startDate: '-100y',
autoclose: true,
startView: 2
});
$('.passport_validate_till').datepicker({
format: "yyyy-mm-dd",
startDate: new Date(dt1),
autoclose: true,
startView: 2
});
var dt4 = '2023-02-15';
var blocked_dates = ["01-01-2023","02-01-2023","06-01-2023","13-01-2023","20-01-2023","27-01-2023","03-02-2023","10-02-2023","17-02-2023","24-02-2023","01-01-2023","02-01-2023","06-01-2023","13-01-2023","20-01-2023","27-01-2023","03-02-2023","10-02-2023","17-02-2023","24-02-2023"];
var available_dates = [];
var fullCapicity_dates = ["15-02-2023","16-02-2023","20-02-2023","21-02-2023","22-02-2023","23-02-2023","27-02-2023","28-02-2023"];
var offDates_dates = ["17-02-2023","18-02-2023","19-02-2023","24-02-2023","25-02-2023","26-02-2023"];
var allowArray = [1,2];
if(checkService == 'Normal')
{
/*if((jQuery.inArray(2, allowArray)!='-1') || (jQuery.inArray(3, allowArray)!='-1') || (jQuery.inArray(4, allowArray)!='-1'))
{
var classFull = 'fullcapspecial';
var tooltipTitle = ' ';
var backDatetitle = 'Not Allowed';
}else{
var classFull = 'fullcap';
var tooltipTitle = 'Slots Full';
var backDatetitle = 'Not Allowed';
}*/
var classFull = 'fullcap';
var tooltipTitle = 'Slots Full';
var backDatetitle = 'Not Allowed';
}else{
var classFull = 'fullcap';
var tooltipTitle = 'Slots Full';
var backDatetitle = 'Not Allowed';
}
$('.app_date').datepicker({
language: "en",
Default: true,
format: "yyyy-mm-dd",
startDate: new Date(dt4),
endDate: '2023-02-28',
autoclose: true,
forceParse:true,
startView: 0,
beforeShowDay: function(date){
var formattedDate = formatDate(date);
if ($.inArray(formattedDate.toString(), blocked_dates) != -1){
return {
enabled : false,
classes: 'inactiveClass',
tooltip: 'Holiday'
};
}
if ($.inArray(formattedDate.toString(), available_dates) != -1){
return {
enabled : true,
classes: 'activeClass',
tooltip: 'Book'
};
}
if ($.inArray(formattedDate.toString(), fullCapicity_dates) != -1){
return {
enabled : false,
classes: classFull,
tooltip: tooltipTitle
};
}
if ($.inArray(formattedDate.toString(), offDates_dates) != -1){
return {
enabled : false,
classes: 'offday',
tooltip: 'Off Day'
};
}
return {
enabled : false,
tooltip: backDatetitle
};
return;
}
});
/*====== CALL POP FOR PL/PT IN NORMAL CASE=======*/
if(checkService == 'Normal')
{
if((jQuery.inArray(2, allowArray)!='-1') || (jQuery.inArray(3, allowArray)!='-1') || (jQuery.inArray(4, allowArray)!='-1'))
{
/*$(document).on('click', '.fullcap,.fullcapspecial', function () {
$(".datepicker").hide();
$('.popupBG').show();
$('#IDBodyPanel').show();
});
$(".popupCloseIcon").click(function() {
$(".popupBG").hide();
$("#IDBodyPanel").hide();
});*/
/*$('input[type=radio][name=serviceChange]').change(function() {
if (this.value == 'Premium') {
$("#premiumService").prop('value', 'GO FOR PREMIUM');
}
else if (this.value == 'Prime') {
$("#premiumService").prop('value', 'GO FOR PRIME TIME');
}
});*/
}
}
/*====== CALL POP FOR PL/PT IN NORMAL CASE=======*/
var eventhandler = function(e) {
e.preventDefault();
}
if (checkService == 'Premium' || checkService == 'Prime' || checkService == 'Premium-Saturday') {
$('input[name="vasId[]"]:checked').each(function() {
$("#vasId"+this.value).bind('click', eventhandler);
});
}
if (checkService != 'Premium')
{
$(document).on('click', '.chkbox', function () {
if($(this).val() == 1)
{
if($(this).is(":checked")){
//$("#vasId6").prop('checked', true);
//$("#vasId6").bind('click', eventhandler);
}else{
//$("#vasId6").prop('checked', false);
//$("#vasId6").unbind('click', eventhandler);
}
}
});
}
});
</script>
Solved
I am working on extracting info from a Databricks job run history.
But even though the data is loaded in the chrome browser, I am unable to see the data in page_source.
I am using Selenium chrome driver in Python
#using this to extract page source
time.sleep(20)
print(driver.page_source)
I am pasting the page source I am getting as output here for your reference.
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="google" content="notranslate"/><meta http-equiv="Content-Language" content="en"/><title>Databricks</title><link rel="preload" href="/pub-conf" as="fetch" crossorigin/><link rel="preload" href="/workspaces" as="fetch" crossorigin/><link rel="icon" href="/favicon.ico"><script defer="defer" src="/js/main.28c3e037.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><script>let logCount = 0;
function error_handler(message, source, lineno, colno, error) {
if (logCount++ > 4) {
return;
}
const ts = Math.round(Date.now() / 1000);
const options = {
method: 'POST',
credentials: 'include',
body: JSON.stringify({uploadTime: ts, items: [
JSON.stringify({
eventId: Array.from(window.crypto.getRandomValues(new Uint32Array(Math.ceil(12 / 8)))).map((x) => x.toString(16)).join('').substring(0, 12),
blob: error && error.stack && error.stack.toString(),
metric:'jsException',
tags: {
eventType: "jsExceptionV3",
jsExceptionMessage: message,
jsExceptionSource: source,
jsExceptionLineno: lineno,
jsExceptionColno: colno,
jsExceptionBeforeInit: true,
},
ts: ts,
}),
]}),
};
fetch('/telemetry?t=' + Date.now(), options);
};
window.onerror = error_handler;
window.onunhandledrejection = function(event) {
error_handler(String(event.reason));
};
window.startupHangTimer = setTimeout(() => {
error_handler("Startup Hang: Did not init within 60 seconds");
}, 60000);
// Prefetch /pubconf, /workspaces, /config
// We wrap this in a function to not pollute the namespace
(function() {
const getParams = (paramsStr) => {
let match;
const pl = /\+/g; // Regex for replacing addition symbol with a space
const search = /([^&=]+)=?([^&]*)/g;
const decode = function decode(s) {
return decodeURIComponent(s.replace(pl, ' '));
};
const urlParams = {};
match = search.exec(paramsStr);
while (match) {
urlParams[decode(match[1])] = decode(match[2]);
match = search.exec(paramsStr);
}
return urlParams;
}
// If we can get it from the params, do that
const params = getParams(window.location.search.substr(1));
const workspaceParam = params?.o;
function fetchWorkspaceConfigUsingParam() {
let configUsingParamProm = null;
let configUsingParamOrgId = null;
if (workspaceParam) {
configUsingParamOrgId = workspaceParam.toString();
configUsingParamProm = fetch('/config', {headers: { 'X-Databricks-Org-Id': configUsingParamOrgId }});
}
return {
configUsingParamProm,
configUsingParamOrgId,
};
}
// Note that this function returns null in cases where there is no workspace or where we want the user to choose a workspace, since we
// are going to redirect the user anyways
const maybeGetOrgId = function(workspaceList, pubConf) {
if (workspaceParam) {
return workspaceParam;
}
// Otherwise we try to infer from the deployment name (apparently this doesn't work for AWS vanity URLs)
if (pubConf.inferOrgIdFromDeploymentName) {
const deploymentName = window.location.hostname
.split('.')
.slice(0, pubConf.numDeploymentNameHostnameLabels)
.join('.');
const targetWorkspace = workspaceList.filter(w => deploymentName === w.deploymentName);
if (targetWorkspace.length > 0) {
return targetWorkspace[0].orgId;
}
}
// If we're just going to redirect the user anyways, don't try to fetch the config
if (pubConf.redirectBrowserOnWorkspaceSelection) {
return null;
}
// Otherwise, if there are either no available workspaces, or multiple confirmed ones, we return null since
// we will redirect the user anyways
const confirmedWorkspaces = workspaceList.filter((workspace) => !workspace.needsConfirmation);
// If there is exactly one confirmed workspace, then we'll pick that one.
// This is the common path for single tenant
if (confirmedWorkspaces.length === 1) {
return confirmedWorkspaces[0].orgId;
}
// otherwise we're not sure what workspace they want, so we don't prefetch
return null;
};
const pubConfProm = fetch('/pub-conf').then(r => {
if (r.status !== 200) {
throw new Error("Pub-conf Prefetch error: " + r.status);
}
return r.json();
}).then(json => window.pubConf = json);
const workspacesProm = fetch('/workspaces').then(r => {
if (r.status !== 200) {
throw new Error("Workspaces Prefetch error: " + r.status);
}
return r.json();
}).then(json => {
window.workspaces = json;
});
const { configUsingParamProm, configUsingParamOrgId } = fetchWorkspaceConfigUsingParam();
window.prefetchedSettingsProm = (async () => {
await Promise.all([pubConfProm, workspacesProm]);
const orgId = maybeGetOrgId(window.workspaces, window.pubConf);
let r;
if (configUsingParamProm && orgId && orgId === configUsingParamOrgId) {
r = await configUsingParamProm;
} else if (orgId != null) {
r = await fetch('/config', {headers: { 'X-Databricks-Org-Id': orgId.toString() }});
} else {
throw new Error("could not determine workspace");
}
if (r.status !== 200) {
throw new Error("Prefetch error: " + r.status);
}
return await r.json();
})();
})();</script><link rel="preload" href="/js/main.28c3e037.js" as="script"><link rel="preload" href="/login/7043.21b43089.chunk.js" as="script"><link rel="preload" href="/login/6499.fedff81a.chunk.js" as="script"><link rel="preload" href="/login/7603.aa36561a.chunk.js" as="script"><link rel="preload" href="/login/5126.a3d96d5a.chunk.js" as="script"><link rel="preload" href="/js/8473.6d11cc58.chunk.js" as="script"><link rel="preload" href="/login/8484.2264fc4c.chunk.js" as="script"><link rel="preload" href="/js/1349.2e50bb47.chunk.js" as="script"><script>function preload(uris) {
uris.forEach(uri => {
const preload = document.createElement("link");
preload.rel = "preload";
preload.href = uri;
preload.as = uri.endsWith(".css") ? "style" : "script";
document.head.appendChild(preload);
});
}
const hash = window.location.hash;
if (hash.indexOf("#notebook/") === 0) {
preload(["/js/265.3ad79cf4.chunk.js","/js/3961.0340df6c.chunk.js","/js/6874.fdee06a1.chunk.js","/js/1435.b44077be.chunk.js","/js/9897.3e95fdd2.chunk.js","/js/2368.b5d6b718.chunk.js","/js/2241.296f6c2a.chunk.js","/js/1831.b4e9f747.chunk.js","/js/8687.d29f7892.chunk.js","/js/3315.cbbda80a.chunk.js","/js/5463.c0497674.chunk.js","/js/6373.1f043b2c.chunk.js","/js/4817.92a286de.chunk.js","/js/4005.60ef1ef1.chunk.js","/js/7177.f2a13d4d.chunk.js","/js/9982.52705ede.chunk.js","/js/9622.32eaae8f.chunk.js","/js/7682.dcc39dcc.chunk.js","/js/1826.3f8ee844.chunk.js","/js/7414.0d648cb1.chunk.js","/js/6638.2cdb7ba7.chunk.js","/js/6617.d700873b.chunk.js","/js/4287.8519cc0d.chunk.js","/js/740.1ba53506.chunk.js","/js/7973.74903f69.chunk.js","/js/2131.0a22c001.chunk.js","/js/2717.5976e517.chunk.js","/js/736.24f4531e.chunk.js","/js/7814.06c77740.chunk.js","/js/8397.bb51b0f1.chunk.js","/js/9957.e844fe05.chunk.js","/css/6823.ef02c8db.chunk.css","/css/9018.b0960582.chunk.css","/css/3061.632ce97e.chunk.css","/css/8687.8261acdc.chunk.css","/css/7177.8239daa4.chunk.css","/css/ReactNotebookView.68ddf7ec.chunk.css"]);
preload(["/js/265.3ad79cf4.chunk.js","/js/3961.0340df6c.chunk.js","/js/6874.fdee06a1.chunk.js","/js/1435.b44077be.chunk.js","/js/5449.26bbd0de.chunk.js","/js/8561.36bc28be.chunk.js","/js/296.352a2fd9.chunk.js","/js/615.7b5a7f25.chunk.js","/js/7414.0d648cb1.chunk.js","/js/6638.2cdb7ba7.chunk.js","/js/6617.d700873b.chunk.js","/js/4287.8519cc0d.chunk.js","/js/740.1ba53506.chunk.js","/js/7973.74903f69.chunk.js","/js/2131.0a22c001.chunk.js","/js/3584.5b823085.chunk.js","/js/8827.4a78799d.chunk.js","/js/2205.cbbcc38e.chunk.js","/js/7994.f058ec6c.chunk.js","/css/6823.ef02c8db.chunk.css","/css/9018.b0960582.chunk.css","/css/ScheduleLink.1a0cef1f.chunk.css"]);
} else if (hash === '') {
preload(["/js/265.3ad79cf4.chunk.js","/js/6638.2cdb7ba7.chunk.js","/js/400.ee52265e.chunk.js","/js/7032.7572d7be.chunk.js","/css/6823.ef02c8db.chunk.css"]);
preload(["/js/265.3ad79cf4.chunk.js","/js/5526.775fd734.chunk.js","/js/6638.2cdb7ba7.chunk.js","/js/400.ee52265e.chunk.js","/js/6362.27654e8a.chunk.js"]);
} else if (hash.indexOf("#job/") === 0) {
if (typeof window !== "undefined" && typeof performance === "object" && performance.timeOrigin) {
preload(['/mfe/jaws/remoteEntry.js?t=' + (performance.timeOrigin)]);
}
}
preload([]);</script><div id="skip-links"></div><uses-legacy-bootstrap data-wrapped-element-id="toolbar"><div id="toolbar"></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="tooltip"><div id="tooltip" class="hidden"><p><span id="value"></span></p></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="global-notification-container"><div id="global-notification-container"></div></uses-legacy-bootstrap><div id="rmmodal-container"></div><uses-legacy-bootstrap data-wrapped-element-id="topbar"><div id="tb-action-banner-container"></div><div id="topbar" style="display: none"><span id="tb-page-title"></span><h1 class="tb-title-wrapper tb-title-wrapper-central"><span class="tb-title"></span> <span class="tb-title-portal"></span> <span class="tb-title-lang"></span><div class="tb-status"><span class="tb-status-msg tb-status-msg-error"></span> <span class="tb-status-msg tb-status-msg-banner"></span> <span class="tb-status-msg tb-status-msg-locked"></span> <span class="tb-status-msg tb-status-msg-connecting">Connecting... </span> <span class="tb-status-msg tb-status-msg-waiting">Still working... </span> <img class="tb-status-spinner" src="/static/media/spinner.gif" alt="spinner"/></div></h1><div class="tb-title-wrapper tb-title-wrapper-right"><div class="tb-trial-msg"></div><div class="tb-title-icons tb-title-icons-right"></div><div class="tb-status presence"><span class="tb-status-msg tb-status-presence"></span></div><div class="tb-notebook-schedule-link"></div><div class="tb-notebook-share-button"></div></div><div id="tb-invite-teammate"></div><div id="tb-upgrade"></div><a class="tb-button tb-button-right tb-button-upgrade" title="Upgrade" target="_blank"><span>Upgrade</span></a></div></uses-legacy-bootstrap><div id="app-root"></div><div id="legacy-app-root"></div><uses-legacy-bootstrap data-wrapped-element-id="filebrowser-popup"><div id="filebrowser-popup" style="display: none"><div class="filebrowser" style="display: none"></div></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="projects-filebrowser-popup"><div id="projects-filebrowser-popup" style="display: none"><div class="filebrowser" style="display: none"></div></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="searchpanel-popup"><div id="searchpanel-popup"><div class="searchpanel" data-panel="Search" style="display: none"></div></div></uses-legacy-bootstrap><div id="search-root"></div><div id="onboarding-checklist"></div><uses-legacy-bootstrap data-wrapped-element-id="title-menu"><div id="title-menu" class="tb-title-menu dropdown-menu" role="menu"></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="hidden"><div id="hidden" style="display: none"></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="history"><div id="history" style="display: none"></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="proxy-endpoints-conn-test-iframe"><div id="proxy-endpoints-conn-test-iframe" style="display: none"></div></uses-legacy-bootstrap><uses-legacy-bootstrap data-wrapped-element-id="debugHelper"><div id="debugHelper" style="z-index: 1000; display: none; position: fixed; right: 190px; bottom: 0px"><div id="debugRoute" style="position: fixed; right: 190px; bottom: 40px"></div><div id="debugCounters" style="color: var(--primary-text-color); position: fixed; right: 50px; bottom: 20px"></div>[OPS] Debug Metrics Requests</div></uses-legacy-bootstrap><script>function addPrefetches(paths) {
paths.forEach(path => {
var element = document.createElement('link');
element.rel = 'prefetch';
element.href = path;
document.getElementsByTagName('head')[0].appendChild(element);
})
}
setTimeout(() => {
addPrefetches(["/media/pin-inactive.76cfbd5a.svg","/media/pin-active.3f997394.svg","/media/jupyter_favicon.e5618ffc.svg","/media/azure_devops_logo_hover.afd8ec9e.svg","/media/azure_devops_logo.6f8531ab.svg","/media/glyphicons-halflings.191ce105.png","/media/newslablight-webfont.43dee4a4.eot","/media/newslablight-webfont.1139d78a.woff2","/media/newslablight-webfont.c8d2ffdf.woff","/media/newslablight-webfont.4d6d4f4c.ttf","/media/newslablight-webfont.6db3f979.svg","/media/databricks-regular-webfont.c3085bea.eot","/media/databricks-regular-webfont.de65de42.woff","/media/databricks-regular-webfont.977f0ff5.ttf","/media/databricks-regular-webfont.2f9a86b4.svg","/media/fontawesome-webfont.03605b24.eot","/media/fontawesome-webfont.c589f72d.woff","/media/fontawesome-webfont.45f9f92a.ttf","/media/fontawesome-webfont.d0ba16d8.svg","/media/Material-Design-Iconic-Font.6ee80f4b.woff2","/media/Material-Design-Iconic-Font.bd9b02bf.woff","/media/Material-Design-Iconic-Font.5a588d6a.ttf","/media/KaTeX_AMS-Regular.8d510e21.woff2","/media/KaTeX_AMS-Regular.363668e4.woff","/media/KaTeX_AMS-Regular.79770839.ttf","/media/KaTeX_Caligraphic-Bold.0408dbd1.woff2","/media/KaTeX_Caligraphic-Bold.dce5f226.woff","/media/KaTeX_Caligraphic-Bold.9958c13a.ttf","/media/KaTeX_Caligraphic-Regular.8cb339d8.woff2","/media/KaTeX_Caligraphic-Regular.a0f19b9a.woff","/media/KaTeX_Caligraphic-Regular.f35e6d32.ttf","/media/KaTeX_Fraktur-Bold.e9f666bf.woff2","/media/KaTeX_Fraktur-Bold.581882ea.woff","/media/KaTeX_Fraktur-Bold.6fc2b891.ttf","/media/KaTeX_Fraktur-Regular.8fafd264.woff2","/media/KaTeX_Fraktur-Regular.d3067917.woff","/media/KaTeX_Fraktur-Regular.37f0101f.ttf","/media/KaTeX_Main-Bold.e4830ce6.woff2","/media/KaTeX_Main-Bold.77475ba5.woff","/media/KaTeX_Main-Bold.b097bb94.ttf","/media/KaTeX_Main-BoldItalic.baab209e.woff2","/media/KaTeX_Main-BoldItalic.5994f793.woff","/media/KaTeX_Main-BoldItalic.4ab8a635.ttf","/media/KaTeX_Main-Italic.fdfec592.woff2","/media/KaTeX_Main-Italic.a15e0ae8.woff","/media/KaTeX_Main-Italic.ac680e98.ttf","/media/KaTeX_Main-Regular.c904829c.woff2","/media/KaTeX_Main-Regular.9d3ff6bd.woff","/media/KaTeX_Main-Regular.ad5bb259.ttf","/media/KaTeX_Math-Italic.d0dd29d1.woff2","/media/KaTeX_Math-Italic.80956401.woff","/media/KaTeX_Math-Italic.75d88e39.ttf","/media/KaTeX_SansSerif-Bold.1849da20.woff2","/media/KaTeX_SansSerif-Bold.5a8b0e8c.woff","/media/KaTeX_SansSerif-Bold.8a18ba89.ttf","/media/KaTeX_SansSerif-Italic.acb5dce2.woff2","/media/KaTeX_SansSerif-Italic.e7517a35.woff","/media/KaTeX_SansSerif-Italic.3e7cf777.ttf","/media/KaTeX_SansSerif-Regular.167f81e8.woff2","/media/KaTeX_SansSerif-Regular.1bb5e535.woff","/media/KaTeX_SansSerif-Regular.7c572bf7.ttf","/media/KaTeX_Script-Regular.49ff882d.woff2","/media/KaTeX_Script-Regular.7e1d6987.woff","/media/KaTeX_Script-Regular.c73c9054.ttf","/media/KaTeX_Size1-Regular.98c1c5ee.woff2","/media/KaTeX_Size1-Regular.6dff5232.woff","/media/KaTeX_Size1-Regular.41fbe509.ttf","/media/KaTeX_Size2-Regular.9f44db0b.woff2","/media/KaTeX_Size2-Regular.758926c6.woff","/media/KaTeX_Size2-Regular.8f1e2ab9.ttf","/media/KaTeX_Size3-Regular.943a01ec.woff2","/media/KaTeX_Size3-Regular.d27d182e.woff","/media/KaTeX_Size3-Regular.32abfb10.ttf","/media/KaTeX_Size4-Regular.31bd0319.woff2","/media/KaTeX_Size4-Regular.47db69ec.woff","/media/KaTeX_Size4-Regular.9ee4a1fd.ttf","/media/KaTeX_Typewriter-Regular.aa9fe3f6.woff2","/media/KaTeX_Typewriter-Regular.663eef93.woff","/media/KaTeX_Typewriter-Regular.73160645.ttf","/media/fontawesome-webfont.8b43027f.eot","/media/fontawesome-webfont.20fd1704.woff2","/media/fontawesome-webfont.f691f37e.woff","/media/fontawesome-webfont.1e59d233.ttf","/media/fontawesome-webfont.c1e38fd9.svg","/media/spritemap.ac65e273.png","/media/spritemap#2x.7410259a.png","/media/SourceCodePro-Regular.otf.b886e5e4.woff2","/media/SourceCodePro-Bold.otf.0fab52a9.woff2","/media/spinner_green.64cba84f.svg","/media/spinner_red.dfdea22c.svg","/login/login.47926ab1.js","/js/main.28c3e037.js","/js/metrics-graphics.240ef397.js","/login/7251.95fc2945.chunk.css","/login/7251.8c659cfe.chunk.js","/media/BMT_logo_large.06a08317.svg","/media/databricks_community_edition.2359b37e.png","/login/6499.fedff81a.chunk.js","/login/7603.aa36561a.chunk.js","/css/1349.6b186478.chunk.css","/js/1349.2e50bb47.chunk.js","/media/partner-connect-icon.8a202243.svg","/media/alert.49c5db30.svg","/media/blocked.a81a311f.svg","/media/book.31f15827.svg","/media/branch.3a7e8c0d.svg","/media/cancelled.2ad6d232.svg","/media/circle_error.e3c3b9a4.svg","/media/cloud.8b8c5eb0.svg","/media/cluster.4a93f2e9.svg","/media/dashboard.8758e581.svg","/media/data-quality.1e5b9672.svg","/media/expand-icon-flipped.77c0871a.svg","/media/fa-columns.76f151f6.svg","/media/fa-table.015b0dc7.svg","/media/failed.789ca99e.svg","/media/filled-gray-circle.7d2d5039.svg","/media/filled-green-circle.ed636499.svg","/media/folder.78745b36.svg","/media/paused.536d6b5d.svg","/media/pending.b8ba238e.svg","/media/query.35fed909.svg","/media/running.ec723323.svg","/media/skipped.b25c88c7.svg","/media/spinner_blue.8d29a816.svg","/media/success.a741e81b.svg","/media/table.7b8cc615.svg","/media/terminated.63ea598d.svg","/media/timed_out.3857e04c.svg","/media/waiting.6f50f9b4.svg","/media/warning.6198e47b.svg","/login/9882.7556e9e0.chunk.js","/login/7043.21b43089.chunk.js","/login/8062.11dbe846.chunk.js","/login/2957.9f99525d.chunk.js","/login/5649.7878ab16.chunk.js","/login/8538.9a6cf4ae.chunk.js","/login/969.6bf80188.chunk.js","/login/862.51b04181.chunk.js","/login/5396.b306568e.chunk.js","/login/9565.9ad08ba9.chunk.js","/login/462.952815d1.chunk.js","/js/9820.5bab95cf.chunk.js","/css/639.768a06d7.chunk.css","/js/639.d8276d0a.chunk.js","/css/8730.f2124aac.chunk.css","/js/8730.7b113aba.chunk.js","/js/6537.6e212bcd.chunk.js","/media/stitch.34c97b52.svg","/media/fivetran.5bb015fe.png","/media/infoworks.7df5f41f.png","/media/qlik.4c6468fd.png","/media/streamsets.3710f31a.png","/media/syncsort.44d5ff89.jpg","/css/GraphqlClustersGetPage.20009756.chunk.css","/js/6471.6b9e370f.chunk.js","/css/NewClustersEditPage.09fbd5ef.chunk.css","/js/4602.7ab61ee7.chunk.js","/css/ClustersMainPage.1c9a080c.chunk.css","/js/2851.a766ba08.chunk.js","/css/SimpleClusterCreatePage.09fbd5ef.chunk.css","/js/7028.313d9947.chunk.js","/css/ClustersCreatePage.09fbd5ef.chunk.css","/js/9463.da593c56.chunk.js","/css/PoolRoutesPages.8e6dfbe2.chunk.css","/js/7274.b3176703.chunk.js","/css/ClusterPoliciesRouteUtils.f3101d86.chunk.css","/js/8540.8d62df5e.chunk.js","/js/3235.b0c75e7f.chunk.js","/css/AdminConsoleView.3cd1bba7.chunk.css","/js/5198.cfc4bbcc.chunk.js","/css/UserSettingsView.92c8234c.chunk.css","/js/9152.ecb54c6d.chunk.js","/media/if_lightbulb.5e2e71fa.svg","/js/6362.27654e8a.chunk.js","/media/import_illustration.4151f89c.svg","/media/notebook_illustration.d0d5ad3b.svg","/media/partner_connect_illustration.8a202243.svg","/media/quickstart_illustration.3c391acf.svg","/media/references_illustration.e67339f9.svg","/js/7032.7572d7be.chunk.js","/media/General_icon.78cbb670.svg","/media/Python_icon.b89e5ec9.svg","/media/R_icon.c159ddc0.svg","/media/Scala_icon.d90ef464.svg","/media/add_data_icon.3b26b6be.svg","/media/code_icon.16b52873.svg","/media/help_doc_icon.679cb6f8.svg","/media/icon-import-data.2fb512d3.svg","/media/icon-new-notebook.2bc783e0.svg","/media/icon-quickstart-notebook.62cf29ed.svg","/media/icon-upload-data-non-drop-zone.e76fe775.svg","/media/icon-upload-data.3e579a80.svg","/media/persona_nav.35794a3b.gif","/css/LibraryView.2e69635a.chunk.css","/js/2662.beedbf76.chunk.js","/js/1511.12475684.chunk.js","/css/ClustersGetMetricsPage.09fbd5ef.chunk.css","/js/5355.bcf82c4c.chunk.js","/js/5148.d308de7a.chunk.js","/css/PipelinesMainPage.46640809.chunk.css","/js/1710.eab7735c.chunk.js","/js/7676.a3d7a7ae.chunk.js","/media/collapsingAllIcon.734ff2cb.svg","/media/expandingAllIcon.53164af4.svg","/js/3214.ae272d39.chunk.js","/js/2667.346c259c.chunk.js","/media/ml_dashboard_ill_automl.e024a05f.svg","/media/ml_dashboard_ill_feature_store.37dd40c0.svg","/media/ml_dashboard_ill_notebook.2993bcc7.svg","/media/ml_dashboard_ill_reference_solutions.8093cd75.svg","/media/ml_dashboard_ill_training.095fbd61.svg","/css/ExperimentObservatoryPage.eae8a832.chunk.css","/js/3637.5912802f.chunk.js","/css/AutoMLConfigurationPage.3af21a7b.chunk.css","/js/2689.7b6b2141.chunk.js","/js/9981.ab3e6f39.chunk.js","/js/5197.fc4b3e76.chunk.js","/js/8732.cb41214f.chunk.js","/js/3449.d55be0e4.chunk.js","/js/199.4c6eb3b4.chunk.js","/js/4286.b1e59071.chunk.js","/js/2384.691a4cb0.chunk.js","/js/3345.5e60f27e.chunk.js","/css/CreateWorkspaceLibraryPage.a7702194.chunk.css","/js/8553.b7373a0f.chunk.js","/css/CreateMlflowExperimentPage.ee2d4c7e.chunk.css","/js/6595.ae5d909c.chunk.js","/css/ScheduleLink.1a0cef1f.chunk.css","/js/7994.f058ec6c.chunk.js","/js/419.a53bb5a3.chunk.js","/css/ReactNotebookView.68ddf7ec.chunk.css","/js/9957.e844fe05.chunk.js","/media/placeholder_pic.157f088b.png","/media/tabbed_results_announce.2c4b9566.gif","/css/DashboardEditView.ea078db7.chunk.css","/js/2882.03efce2b.chunk.js","/css/DashboardPresentView.fceb6112.chunk.css","/js/8985.c89f21e8.chunk.js","/css/TableGetPage.e5f37737.chunk.css","/js/4227.63f45c4a.chunk.js","/js/2184.8a58eb28.chunk.js","/js/8155.c9616b56.chunk.js","/js/5402.61f8dd3d.chunk.js","/js/5244.61ebb5cb.chunk.js","/css/2009.09fbd5ef.chunk.css","/js/2009.05795c52.chunk.js","/media/mlflow_cluster_libraries_icon.adffc652.svg","/media/mlflow_cluster_spec_icon.001d116c.svg","/media/mlflow_notebook_revision_icon.8f838dbc.svg","/js/3080.c9c93b1f.chunk.js","/js/5290.536d9da4.chunk.js","/media/logged_model.dd9b21ff.svg","/media/registered_model.f2b0e698.svg","/media/view_notebook_revision.06996110.svg","/js/4136.0c92b01d.chunk.js","/js/5122.77668f56.chunk.js","/media/countries.geo.da867aec.json","/media/japan.prefectures.geo.503032a2.json","/media/usa-albers.geo.4d6ceca8.json","/js/2713.f27cb942.chunk.js","/js/7561.8de45682.chunk.js","/js/265.3ad79cf4.chunk.js","/js/3961.0340df6c.chunk.js","/js/6874.fdee06a1.chunk.js","/css/6823.ef02c8db.chunk.css","/js/1435.b44077be.chunk.js","/js/9897.3e95fdd2.chunk.js","/css/9018.b0960582.chunk.css","/css/3061.632ce97e.chunk.css","/js/2368.b5d6b718.chunk.js","/js/2241.296f6c2a.chunk.js","/js/1831.b4e9f747.chunk.js","/css/8687.8261acdc.chunk.css","/js/8687.d29f7892.chunk.js","/js/5449.26bbd0de.chunk.js","/js/3315.cbbda80a.chunk.js","/js/5463.c0497674.chunk.js","/js/6373.1f043b2c.chunk.js","/js/4817.92a286de.chunk.js","/js/9487.6d0c3e50.chunk.js","/js/4005.60ef1ef1.chunk.js","/css/7177.8239daa4.chunk.css","/js/7177.f2a13d4d.chunk.js","/js/9982.52705ede.chunk.js","/js/8561.36bc28be.chunk.js","/js/9622.32eaae8f.chunk.js","/js/7682.dcc39dcc.chunk.js","/js/1202.1651745c.chunk.js","/js/296.352a2fd9.chunk.js","/js/615.7b5a7f25.chunk.js","/login/5126.1b33304e.chunk.css","/login/5126.a3d96d5a.chunk.js","/js/5526.775fd734.chunk.js","/js/3112.229db2c0.chunk.js","/css/9097.b7c5aca9.chunk.css","/js/789.7055c3e7.chunk.js","/js/6122.a583f800.chunk.js","/js/3953.bc4a0338.chunk.js","/js/5850.b9610775.chunk.js","/css/8473.a91be41f.chunk.css","/js/8473.6d11cc58.chunk.js","/css/9822.c697d92c.chunk.css","/js/9822.a6f219f0.chunk.js","/js/1826.3f8ee844.chunk.js","/login/7628.be1062f4.chunk.js","/js/2180.77c8b226.chunk.js","/js/3949.0ba9a432.chunk.js","/js/177.7d26e136.chunk.js","/js/2122.aeb0bf45.chunk.js","/js/7414.0d648cb1.chunk.js","/js/6638.2cdb7ba7.chunk.js","/js/6617.d700873b.chunk.js","/js/4287.8519cc0d.chunk.js","/js/740.1ba53506.chunk.js","/js/7973.74903f69.chunk.js","/js/2131.0a22c001.chunk.js","/js/5489.e0232314.chunk.js","/js/2717.5976e517.chunk.js","/media/us-map.6cab3846.json","/media/world-map.282fccf1.json","/media/ellipse-2s-30px.df5b6e08.gif","/js/3584.5b823085.chunk.js","/js/520.57827eea.chunk.js","/js/6267.26b62d2c.chunk.js","/js/1342.f3c1945c.chunk.js","/js/736.24f4531e.chunk.js","/js/400.ee52265e.chunk.js","/js/8827.4a78799d.chunk.js","/login/8484.2264fc4c.chunk.js","/media/spinner.7aa77051.svg","/media/bmt-favicon.dfa4ca84.ico","/js/7814.06c77740.chunk.js","/js/9418.cfc92d91.chunk.js","/js/2630.4613696c.chunk.js","/js/367.378e8204.chunk.js","/js/1913.37480a3a.chunk.js","/js/3846.23b54ba1.chunk.js","/js/2205.cbbcc38e.chunk.js","/js/8397.bb51b0f1.chunk.js","/js/4332.4717d0c6.chunk.js","/js/2960.d7334d50.chunk.js","/js/5397.089d60be.chunk.js","/js/9628.69417888.chunk.js","/js/9167.c719483d.chunk.js","/js/4188.000cbe6c.chunk.js","/js/438.be5d16dd.chunk.js","/static/media/spinner.gif","/login/DB_Azure_Lockup_2x.png","/login/bootstrap.min.css","/login/databricks_ce_icon.svg","/login/databricks_logoTM_rgb_TM.svg","/login/favicon.ico","/login/logo_2020/azure_databricks.png","/login/logo_2020/databricks.svg","/login/logo_2020/databricks_community_edition.png","/delta_sharing/databricks.svg","/delta_sharing/download.svg","/delta_sharing/retrieve_config.html","/delta_sharing/sharing.css","/delta_sharing/sharing.js","/delta_sharing/logo/apachespark.png","/delta_sharing/logo/atscale.png","/delta_sharing/logo/azuresynapse.png","/delta_sharing/logo/bigquery.png","/delta_sharing/logo/databricks.png","/delta_sharing/logo/dremio.png","/delta_sharing/logo/looker.png","/delta_sharing/logo/pandas.png","/delta_sharing/logo/powerbi.png","/delta_sharing/logo/presto.png","/delta_sharing/logo/python.png","/delta_sharing/logo/qlik.png","/delta_sharing/logo/starburst.png","/delta_sharing/logo/tableau.png","/delta_sharing/logo/trino.png","/static/iframe.html","/static/css/sparkui-iframe.css","/static/js/heap/heap-1473692602.js","/static/js/heap/heap-210092139.js","/static/js/heap/heap-3428506230.js","/favicon.ico","/login.html",])
}, 30000)</script><div id="emotion-container-webapp-css"></div></body></html>
Can someone help me extract the data after all this javascript is rendered?
I'm trying to parse https://www.houzz.ru/professionals/remont-i-otdelka-kvartir-i-domov
Below is the code I am using.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time
chromedriver = r'E:/ProgrammFiles/chromdriver/chromedriver.exe'
opts = Options()
opts.add_argument("user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
opts.add_argument('-headless')
browser = webdriver.Chrome(service=Service(r'E:/ProgrammFiles/chromdriver/chromedriver.exe'), options=opts)
browser.get('https://www.houzz.ru/professionals/remont-i-otdelka-kvartir-i-domov')
content = ''
while True:
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(1)
if content != browser.page_source:
content = browser.page_source
continue
else:
break
time.sleep(10)
requiredHtml = browser.execute_script("return document.body.innerHTML;")
print(requiredHtml)
This is the response I am getting.
отделки выполняла ...Professionals","namespace":"HOUZZ","experienceName":"BROWSE_PROFESSIONALS","siteId":"106","siteName":"HOUZZ_RU"},"disableLegacyJsRes":true,"shouldDeferPageImpressionLogging":false}</script><script type="text/javascript">HZ = HZ || {}; HZ.ctx = JSON.parse(document.getElementById("hz-ctx").textContent);</script><script id="hz-js-async-hint" type="text/javascript">window.hzResAsync = true;</script><script id="hz-js-default" type="text/javascript">"use strict";
function _typeof(obj) { "#babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
if (window.HZ || (window.HZ = {}), window.HZ.jUtils || (window.HZ.jUtils = {
eventCounter: 0
}), Array.isArray || (Array.isArray = function (e) {
return "[object Array]" === Object.prototype.toString.call(e);
}), Array.prototype.includes || (Array.prototype.includes = function (e, t) {
return void 0 === t && (t = 0), -1 !== this.indexOf(e, t);
}), Event.prototype.preventDefault || (Event.prototype.preventDefault = function () {
this.returnValue = !1;
}), Event.prototype.stopPropagation || (Event.prototype.stopPropagation = function () {
this.cancelBubble = !0;
}), Element.prototype.closest || (Element.prototype.closest = function (e) {
var t = this;
do {
if (Element.prototype.matches.call(t, e)) return t;
t = t.parentElement || t.parentNode;
} while (null !== t && 1 === t.nodeType);
return null;
}), window.NodeList && !NodeList.prototype.forEach && (NodeList.prototype.forEach = Array.prototype.forEach), "function" != typeof Element.prototype.addEventListener) {
var eventListeners = [],
_addEventListener = function _addEventListener(e, t) {
var n = this,
o = function o(e) {
e.target = e.srcElement, e.currentTarget = n, void 0 !== t.handleEvent ? t.handleEvent(e) : t.call(n, e);
};
if ("DOMContentLoaded" == e) {
var r = function r(e) {
"complete" == document.readyState && o(e);
};
if (document.attachEvent("onreadystatechange", r), eventListeners.push({
object: this,
type: e,
listener: t,
wrapper: r
}), "complete" == document.readyState) {
var i = new Event();
i.srcElement = window, r(i);
}
} else this.attachEvent("on" + e, o), eventListeners.push({
object: this,
type: e,
listener: t,
wrapper: o
});
},
_removeEventListener = function _removeEventListener(e, t) {
for (var n = 0; n < eventListeners.length;) {
var o = eventListeners[n];
if (o.object == this && o.type == e && o.listener == t) {
"DOMContentLoaded" == e ? this.detachEvent("onreadystatechange", o.wrapper) : this.detachEvent("on" + e, o.wrapper), eventListeners.splice(n, 1);
break;
}
++n;
}
};
Element.prototype.addEventListener = _addEventListener, Element.prototype.removeEventListener = _removeEventListener, HTMLDocument && (HTMLDocument.prototype.addEventListener = _addEventListener, HTMLDocument.prototype.removeEventListener = _removeEventListener), Window && (Window.prototype.addEventListener = _addEventListener, Window.prototype.removeEventListener = _removeEventListener);
}
function scriptCreationFallback(e) {
document.write("<script src='" + e + "' defer><\/script>");
}
function scriptLoadCallback(e) {
for (; window.hzAsync.pendingScripts[0] && ("loaded" == window.hzAsync.pendingScripts[0].readyState || "complete" == window.hzAsync.pendingScripts[0].readyState);) {
var t = window.hzAsync.pendingScripts.shift();
t.onreadystatechange ? t.onreadystatechange = null : t.removeEventListener && t.removeEventListener("load", scriptLoadCallback), window.hzAsync.firstScript.parentNode.insertBefore(t, window.hzAsync.firstScript);
}
}
function loadScript(e, t) {
if (e) try {
var n;
window.hzAsync.firstScript && "async" in window.hzAsync.firstScript ? ((n = document.createElement("script")).async = !1, n.src = e, n.crossOrigin = "anonymous", document.head.appendChild(n)) : window.hzAsync.firstScript && window.hzAsync.firstScript.readyState ? (n = document.createElement("script"), window.hzAsync.pendingScripts.push(n), n.addEventListener ? n.addEventListener("load", scriptLoadCallback, !1) : n.readyState && (n.onreadystatechange = scriptLoadCallback), n.src = e) : scriptCreationFallback(e);
} catch (t) {
scriptCreationFallback(e);
} else t();
}
function getCookie(e) {
for (var t = e + "=", n = document.cookie.split(";"), o = 0, r = n.length; o < r; o++) {
for (var i = n[o]; " " === i.charAt(0);) {
i = i.substring(1);
}
if (0 === i.indexOf(t)) return i.substring(t.length);
}
return "";
}
function logEventPixel(e, t, n, o) {
if (e) {
var r = e.replace(/%2F/g, "[[2f]]");
try {
var i = new Image();
document.body.appendChild(i), i.onload = function () {
n && n();
}, "function" == typeof o && (i.onerror = function (e) {
o(e);
}), i.className = t, i.src = r, i.alt = "", i.style.position = "absolute", i.style.left = "-100px", i.style.width = "1px", i.style.height = "1px", i.style.top = "-100px";
} catch (e) {}
}
}
function getPageTransitionInfo() {
var e = getCookie("hzd"),
t = {};
if (e && "string" == typeof e) try {
var n = (e = decodeURIComponent(e)).split(":");
6 === n.length && (t.requestId = n[0], t.objId = n[1], t.compId = n[2], t.scopeId = n[3], t.posId = n[4], t.anchorText = n[5]);
} catch (e) {
t = {};
}
return t;
}
function logPageImpression() {
if (document.images && HZ.ctx) {
var e = getPageTransitionInfo() || "",
t = HZ.ctx.rid;
if ("object" == _typeof(e)) {
e.requestIdOverride && (t = e.requestIdOverride, delete e.requestIdOverride);
try {
e = JSON.stringify(e);
} catch (t) {
e = "";
}
}
var n = "",
o = "";
HZ.ctx.geo && (n = HZ.ctx.geo.locale, o = HZ.ctx.geo.siteId);
var r = -1;
HZ.ctx.domainId && (r = HZ.ctx.domainId), logEventPixel(HZ.ctx.logcmd + "evtName=page_impression/evtRequestId=" + encodeURIComponent(t) + "/evtMessage=" + encodeURIComponent(e) + "/evtLocale=" + encodeURIComponent(n) + "/evtSiteId=" + encodeURIComponent(o) + "/evtDomainId=" + encodeURIComponent(r) + "/evtDM=2/evtV=" + encodeURIComponent(HZ.ctx.consentedVisitorIdToken) + "/iid=" + Math.ceil(1e16 * Math.random()) + "/ec=0", "page_impression", null, function (e) {
HZ.__pageImpressionError = e;
});
}
}
if ("function" != typeof Object.entries && (Object.entries = function (e) {
for (var t = Object.keys(e), n = t.length, o = new Array(n); n--;) {
o[n] = [t[n], e[t[n]]];
}
return o;
}), "function" != typeof Object.values && (Object.values = function (e) {
return Object.keys(e).map(function (t, n) {
return e[t];
});
}), document.addEventListener("DOMContentLoaded", function (e) {
HZ.ctx.xdEventUrl && loadScript(HZ.ctx.xdEventUrl), HZ.ctx.eelopi && !HZ.ctx.shouldDeferPageImpressionLogging && logPageImpression();
}), HZ && HZ.ctx && HZ.ctx.shouldDeferPageImpressionLogging) {
var oldOnLoad = window.onload;
window.onload = function () {
oldOnLoad && oldOnLoad(), HZ.ctx.eelopi && logPageImpression();
};
}
function supportsES6() {
try {
return new Function("(a = 0) => a"), !0;
} catch (e) {
return !1;
}
}
function loadAllScriptsAsync(e, t) {
var n;
if (e) {
if (!window.Intl && HZ.jbc && HZ.jbc.intlPolyfill) for (var o = 0, r = e.length; o < r; o++) {
if (-1 !== e[o].indexOf("vendor")) {
e.splice(o + 1, 0, HZ.jbc.intlPolyfill);
break;
}
}
if (HZ.jbc && HZ.jbc.es6Polyfill && !supportsES6()) for (var i = 0, c = e.length; i < c; i++) {
if (-1 !== e[i].indexOf("vendor")) {
e.splice(i + 1, 0, HZ.jbc.es6Polyfill);
break;
}
}
for (; n = e.shift();) {
n && loadScript(n, function () {});
}
}
}
window.hzAsync = {
pendingScripts: [],
firstScript: document.scripts && document.scripts.length ? document.scripts[0] : null
};</script><script type="text/javascript">window.loadAllScriptsAsync(['//sk.hzcdn.com/j/res?type=l10n&locale=ru-RU&pageName=browseProfessionalsDirectory&version=20220224150841&t=l10n.js&kcan=release20220224150841288754666b','//sk.hzcdn.com/j/res?type=assets&locale=ru-RU&version=20220224150841&t=asset.js&kcan=release20220224150841288754666b','//sk.hzcdn.com/jscripts/jquery-3.1.1.min.js?kcan=release20220224150841288754666b','//sk.hzcdn.com/assets/vendor_4908c5c3394b3a62b1b9.bundle.js?kcan=release20220224150841288754666b','/jscripts/branch/branchMetrics.js','//sk.hzcdn.com/assets/browseProfessionalsDirectory_87ab82ea9d7c27a777ca.bundle.js?kcan=release20220224150841288754666b']);</script><img class="page_impression" src="//www.houzz.com/js/log?p=evtName=page_impression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=3711251106415774/ec=0" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=client_perf_time/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22name%22%3A%22https%3A[[2f]][[2f]]www.houzz.ru[[2f]]professionals[[2f]]remont-i-otdelka-kvartir-i-domov%22%2C%22entryType%22%3A%22navigation%22%2C%22startTime%22%3A0%2C%22duration%22%3A5321.5%2C%22initiatorType%22%3A%22navigation%22%2C%22nextHopProtocol%22%3A%22h2%22%2C%22workerStart%22%3A0%2C%22redirectStart%22%3A0%2C%22redirectEnd%22%3A0%2C%22fetchStart%22%3A0.20000004768371582%2C%22domainLookupStart%22%3A2308%2C%22domainLookupEnd%22%3A2338.2000000476837%2C%22connectStart%22%3A2338.2000000476837%2C%22connectEnd%22%3A2643.5%2C%22secureConnectionStart%22%3A2383.600000023842%2C%22requestStart%22%3A2643.7000000476837%2C%22responseStart%22%3A4029.5%2C%22responseEnd%22%3A4327.600000023842%2C%22transferSize%22%3A168197%2C%22encodedBodySize%22%3A167897%2C%22decodedBodySize%22%3A1669744%2C%22serverTiming%22%3A%5B%5D%2C%22workerTiming%22%3A%5B%5D%2C%22unloadEventStart%22%3A0%2C%22unloadEventEnd%22%3A0%2C%22domInteractive%22%3A4384.399999976158%2C%22domContentLoadedEventStart%22%3A4384.700000047684%2C%22domContentLoadedEventEnd%22%3A4386.600000023842%2C%22domComplete%22%3A5321.5%2C%22loadEventStart%22%3A5321.5%2C%22loadEventEnd%22%3A5321.5%2C%22type%22%3A%22navigate%22%2C%22redirectCount%22%3A0%2C%22first-paint%22%3A4202%2C%22first-contentful-paint%22%3A4202%2C%22istl%22%3Afalse%2C%22cn%22%3A%22browseProfessionalsDirectory%22%2C%22pn%22%3A%22browseProfessionalsDirectory%22%2C%22testName%22%3A%7B%22browse_gql_migration%22%3A%22off%22%2C%22directory_gql_migration%22%3A%22c%22%7D%2C%22env%22%3A%22j%22%2C%22isCached%22%3Afalse%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=5234927537908136/ec=1" class="hz-logger-pixel client_perf_time" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><iframe id="history-iframe" src="javascript:""" style="display: none;"></iframe><div><div class="hz-popover--bottom pointer-offset--50 hz-popover has-pointer pointer--medium hzm-pro-search-controls__location-cta" style="position: absolute; top: 620.234px; left: 124.961px; border-width: 0px; border-style: solid; background-color: rgb(68, 68, 68); color: rgb(255, 255, 255); padding: 10px 15px;"><div style="width: 220px;"><div class="prm">Укажите местоположение, чтобы найти экспертов поблизости</div><button class="btn btn-link hzm-pro-search-controls__location-tooltip-close mts mrs" type="button"><svg class="svg-icon " viewBox="0 0 20 20" width="1em" height="1em" focusable="false" aria-hidden="true" role="presentation" style="fill: currentcolor; font-size: 1em;"><path d="M17.576 5.076l-2.653-2.652-4.924 4.925-4.924-4.925-2.652 2.653 4.925 4.924-4.925 4.924 2.653 2.653L10 12.653l4.924 4.925 2.653-2.653-4.925-4.924 4.925-4.924z"></path></svg></button></div><div class="hz-popover__pointer hz-popover__pointer--inner" style="border-color: rgb(68, 68, 68);"></div></div></div><img src="//www.houzz.com/js/log?p=evtName=hzpro_upsell_impression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22pro_lead_source%22%3A%22Direct%22%2C%22event_source%22%3A%22header%22%2C%22package_category%22%3A%22core%22%2C%22user_id%22%3Anull%2C%22user_type%22%3A-1%2C%22is_paid_pro%22%3Afalse%2C%22is_impersonated%22%3Afalse%2C%22is_admin%22%3Afalse%2C%22is_mobile%22%3Afalse%2C%22page_name%22%3A%22browseProfessionalsDirectory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=5911521926982624/ec=2" class="hz-logger-pixel hzpro_upsell_impression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A64253719%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=2220830144426012/ec=3" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A57721258%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=3951072444511319/ec=4" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A65757428%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=683503507181580/ec=5" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A56354784%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=961242228540156/ec=6" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=videoConsultationUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A56354784%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=818066732422021/ec=7" class="hz-logger-pixel videoConsultationUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A52889918%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=1285249202298114/ec=8" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A58286874%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=1552085968097590/ec=9" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A61586142%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=7141577832222390/ec=10" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A64842547%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=54788068219763/ec=11" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=featuredReviewsUserImpression/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22authorId%22%3A23415196%2C%22isMobile%22%3Afalse%2C%22isSignedIn%22%3Afalse%2C%22page%22%3A%22pro-directory%22%2C%22eventFilter%22%3A%22industry_solution%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=5171107295118558/ec=12" class="hz-logger-pixel featuredReviewsUserImpression" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;"><img src="//www.houzz.com/js/log?p=evtName=google_one_tap_not_displayed_v2/evtRequestId=e9ac2935-5608-403c-81e6-56f868351128/evtMessage=%7B%22device%22%3A%22desktop%22%2C%22pageName%22%3A%22browseProfessionalsDirectory%22%2C%22reason%22%3A%22opt_out_or_no_session%22%7D/evtLocale=ru-RU/evtSiteId=106/evtDomainId=180500/evtDM=2/evtV=1645973597_af123702-e29b-438a-8013-c65280828350_5840bd6f8506b145e268c33c372977e3/iid=3337074405007876/ec=13" class="hz-logger-pixel google_one_tap_not_displayed_v2" alt="" style="position: absolute; left: -100px; width: 1px; height: 1px; top: -100px;">
<script type="text/javascript" id="">!function(b,e,f,g,a,c,d){b.fbq||(a=b.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},b._fbq||(b._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[],c=e.createElement(f),c.async=!0,c.src=g,d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(c,d))}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");fbq("init","295742887240801");fbq("track","PageView");</script>
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=295742887240801&ev=PageView&noscript=1"></noscript>
<script type="text/javascript" id="">!function(b,e,f,g,a,c,d){b.fbq||(a=b.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},b._fbq||(b._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[],c=e.createElement(f),c.async=!0,c.src=g,d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(c,d))}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");fbq("init","1374436976058630");fbq("track","PageView");</script>
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1374436976058630&ev=PageView&noscript=1"></noscript>
<script type="text/javascript" id="" src="https://s.yimg.jp/images/listing/tool/cv/ytag.js"></script><script type="text/javascript" id="" src="https://js.adsrvr.org/up_loader.1.1.0.js"></script>
<script type="text/javascript" id="">!function(b,e,f,g,a,c,d){b.fbq||(a=b.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},b._fbq||(b._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[],c=e.createElement(f),c.async=!0,c.src=g,d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(c,d))}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");fbq("init","295742887240801");fbq("set","agent","tmgoogletagmanager","295742887240801");fbq("track","PageView");</script>
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=295742887240801&ev=PageView&noscript=1"></noscript>
<script src="https://siteintercept.qualtrics.com/dxjsmodule/CoreModule.js?Q_CLIENTVERSION=1.66.1&Q_CLIENTTYPE=web&Q_BRANDID=houzz" defer=""></script><div style="width:0px; height:0px; display:none; visibility:hidden;" id="batBeacon77119120009"><img style="width:0px; height:0px; display:none; visibility:hidden;" id="batBeacon161098445390" width="0" height="0" alt="" src="https://bat.bing.com/action/0?ti=134614806&tm=gtm002&Ver=2&mid=1debbd4e-6ba4-4404-85d9-2f4810cacbdc&sid=008172b097dd11ecb0575de57b6ec4e5&vid=0081a29097dd11eca39ba76be5be369d&vids=1&pi=0&lg=ru&sw=800&sh=600&sc=24&tl=15%20%D0%BB%D1%83%D1%87%D1%88%D0%B8%D1%85%3A%20%D0%A0%D0%B5%D0%BC%D0%BE%D0%BD%D1%82%20%D0%B8%20%D0%BE%D1%82%D0%B4%D0%B5%D0%BB%D0%BA%D0%B0%20%D0%BA%D0%B2%D0%B0%D1%80%D1%82%D0%B8%D1%80%20%D0%B8%20%D0%B4%D0%BE%D0%BC%D0%BE%D0%B2,%20%D0%BA%D0%BE%D0%BC%D0%BF%D0%B0%D0%BD%D0%B8%D0%B8%20%D0%BF%D0%BE%20%D1%80%D0%B5%D0%BC%D0%BE%D0%BD%D1%82%D1%83%20%D0%BA%D0%B2%D0%B0%D1%80%D1%82%D0%B8%D1%80%20%D0%B8%20%D1%87%D0%B0%D1%81%D1%82%D0%BD%D1%8B%D0%B5%20%D0%BC%D0%B0%D1%81%D1%82%D0%B5%D1%80%D0%B0%20%7C%20Houzz%20%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F&p=https%3A%2F%2Fwww.houzz.ru%2Fprofessionals%2Fremont-i-otdelka-kvartir-i-domov&r=<=5322&evt=pageLoad&msclkid=N&sv=1&rn=516824"></div><iframe id="epik_localstore" src="https://www.pinterest.com/ct.html" width="1" height="1" style="display: none;"></iframe>
<script type="text/javascript" id="">window.yjDataLayer=window.yjDataLayer||[];function ytag(){yjDataLayer.push(arguments)}ytag({type:"ycl_cookie"});</script>
<script type="text/javascript" id="">"function"===typeof ttd_dom_ready&&ttd_dom_ready(function(){if("function"===typeof TTDUniversalPixelApi){var a=new TTDUniversalPixelApi;a.init("njgpa0b",["8q0k4ag"],"https://insight.adsrvr.org/track/up")}});</script><iframe id="universal_pixel_8q0k4ag" height="0" width="0" style="display:none;" src="https://insight.adsrvr.org/track/up?adv=njgpa0b&ref=https%3A%2F%2Fwww.houzz.ru%2Fprofessionals%2Fremont-i-otdelka-kvartir-i-domov&upid=8q0k4ag&upv=1.1.0" title="TTD Universal Pixel"></iframe>
The first line is the json, but it is somehow cut off and the information that is not expected is stored in it.
I need to get either json stored in <script id="hz-ctx" type="application/json">...</script> or directly html, which can later be parsed using beautifulsoup.
Please advise how this can be done on this site.
I'm building a pyqt5 desktop interface where I'm using QWebEngineView to show a html file where I show a Leaflet map. This is working fine.
The next step is to export all features the user added to the map. When I click on "Export Features" on the map nothing happen, but when I open the same html file on my Chromium web browser, the "Export feature" opens the download dialog fine.
PyQt5 script:
self.MainWindow.webMapViewer = QtWebEngineWidgets.QWebEngineView()
self.MainWindow.webPageLayout.addWidget(self.MainWindow.webMapViewer)
self.html_path = os.path.split(os.path.abspath(__file__))[0] + r'/html/test.html'
self.MainWindow.webMapViewer.load(QtCore.QUrl().fromLocalFile(self.html_path))
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<title>FazMaraneyRGB_transparent_mosaic_group1</title>
<!-- Leaflet -->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<!-- Leaflet.draw -->
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw#0.4.1/dist/leaflet.draw.css" />
<script src="https://unpkg.com/leaflet-draw#0.4.1/dist/leaflet.draw.js"></script>
<!-- Leaflet Ajax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<!-- Leaflet Measument -->
<link rel="stylesheet" href="http://ljagis.github.io/leaflet-measure/leaflet-measure.css" />
<script src="http://ljagis.github.io/leaflet-measure/leaflet-measure.min.js"></script>
<style>
body { margin:0; padding:0; }
body, table, tr, td, th, div, h1, h2, input { font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif; font-size: 11pt; }
#map { position:absolute; top:0; bottom:0; width:100%; } /* full size */
.ctl {
padding: 2px 10px 2px 10px;
background: white;
background: rgba(255,255,255,0.9);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
text-align: right;
}
.title {
font-size: 18pt;
font-weight: bold;
}
.src {
font-size: 10pt;
}
#delete, #export {
position: absolute;
top:100px;
right:10px;
z-index:100;
background:white;
color:black;
padding:6px;
border-radius:4px;
font-family: 'Helvetica Neue';
cursor: pointer;
font-size:12px;
text-decoration:none;
}
#export {
top:130px;
}
</style>
</head>
<body>
<div id='map'></div>
<div id='delete'>Delete Features</div>
<a href='#' id='export'>Export Features</a>
<script>
/* **** Leaflet **** */
// Base layers
// .. OpenStreetMap
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© OpenStreetMap contributors'});
// .. White background
var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg==");
// Overlay layers (TMS)
var lyr1 = L.tileLayer('./tiles/{z}/{x}/{y}.png', {tms: true, maxZoom: 22, opacity: 0.9, attribution: ""});
// Map
var map = L.map('map', {
measureControl: true,
center: [-18.3604868606589, -52.694255477616245],
zoom: 22,
minZoom: 0,
maxZoom: 22,
layers: [osm]
});
lyr1.addTo(map);
//Geojson Layers
var basemaps = {"OpenStreetMap": osm, "Without background": white}
var overlaymaps = {"Layer 1": lyr1}
// Title
var title = L.control();
title.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'ctl title');
this.update();
return this._div;
};
title.update = function(props) {
this._div.innerHTML = "FazMaraneyRGB_transparent_mosaic_group1";
};
title.addTo(map);
// Note
var src = 'Generated by Hawkit';
var title = L.control({position: 'bottomleft'});
title.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'ctl src');
this.update();
return this._div;
};
title.update = function(props) {
this._div.innerHTML = src;
};
title.addTo(map);
var featureGroup = L.featureGroup().addTo(map);
var drawControl = new L.Control.Draw({
edit: {
featureGroup: featureGroup
}
}).addTo(map);
map.on('draw:created', function(e) {
// Each time a feaute is created, it's added to the over arching feature group
featureGroup.addLayer(e.layer);
});
// on click, clear all layers
document.getElementById('delete').onclick = function(e) {
featureGroup.clearLayers();
}
document.getElementById('export').onclick = function(e) {
// Extract GeoJson from featureGroup
var data = featureGroup.toGeoJSON();
// Stringify the GeoJson
var convertedData = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(data));
// Create export
document.getElementById('export').setAttribute('href', 'data:' + convertedData);
document.getElementById('export').setAttribute('download','data.geojson');
}
// Add base layers
L.control.layers(basemaps, overlaymaps, {collapsed: true}).addTo(map);
// Fit to overlay bounds (SW and NE points with (lat, lon))
map.fitBounds([[-18.36827062251916, -52.6871074784942], [-18.35270287637126, -52.7014028427423]]);
</script>
</body>
</html>
That popup window is generated by the browser, in the case of QWebEngine we must create it. To start, the signal indicating the download must be detected, and this signal is downloadRequested from the QWebEngineProfile. That signal sends us a QWebEngineDownloadItem object that handles the download, in it we create a dialog window with the help of QFileDialog. For this case we will create a custom QWebEnginePage as shown below:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<title>FazMaraneyRGB_transparent_mosaic_group1</title>
<!-- Leaflet -->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<!-- Leaflet.draw -->
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw#0.4.1/dist/leaflet.draw.css" />
<script src="https://unpkg.com/leaflet-draw#0.4.1/dist/leaflet.draw.js"></script>
<!-- Leaflet Ajax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<!-- Leaflet Measument -->
<link rel="stylesheet" href="http://ljagis.github.io/leaflet-measure/leaflet-measure.css" />
<script src="http://ljagis.github.io/leaflet-measure/leaflet-measure.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
body,
table,
tr,
td,
th,
div,
h1,
h2,
input {
font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif;
font-size: 11pt;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
/* full size */
.ctl {
padding: 2px 10px 2px 10px;
background: white;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
text-align: right;
}
.title {
font-size: 18pt;
font-weight: bold;
}
.src {
font-size: 10pt;
}
#delete,
#export {
position: absolute;
top: 100px;
right: 10px;
z-index: 100;
background: white;
color: black;
padding: 6px;
border-radius: 4px;
font-family: 'Helvetica Neue';
cursor: pointer;
font-size: 12px;
text-decoration: none;
}
#export {
top: 130px;
}
</style>
</head>
<body>
<div id='map'></div>
<div id='delete'>Delete Features</div>
<a href='#' id='export'>Export Features</a>
<script>
/* **** Leaflet **** */
// Base layers
// .. OpenStreetMap
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
});
// .. White background
var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg==");
// Overlay layers (TMS)
var lyr1 = L.tileLayer('./tiles/{z}/{x}/{y}.png', {
tms: true,
maxZoom: 22,
opacity: 0.9,
attribution: ""
});
// Map
var map = L.map('map', {
measureControl: true,
center: [-18.3604868606589, -52.694255477616245],
zoom: 22,
minZoom: 0,
maxZoom: 22,
layers: [osm]
});
lyr1.addTo(map);
//Geojson Layers
var basemaps = {
"OpenStreetMap": osm,
"Without background": white
}
var overlaymaps = {
"Layer 1": lyr1
}
// Title
var title = L.control();
title.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'ctl title');
this.update();
return this._div;
};
title.update = function(props) {
this._div.innerHTML = "FazMaraneyRGB_transparent_mosaic_group1";
};
title.addTo(map);
// Note
var src = 'Generated by Hawkit';
var title = L.control({
position: 'bottomleft'
});
title.onAdd = function(map) {
this._div = L.DomUtil.create('div', 'ctl src');
this.update();
return this._div;
};
title.update = function(props) {
this._div.innerHTML = src;
};
title.addTo(map);
var featureGroup = L.featureGroup().addTo(map);
var drawControl = new L.Control.Draw({
edit: {
featureGroup: featureGroup
}
}).addTo(map);
map.on('draw:created', function(e) {
// Each time a feaute is created, it's added to the over arching feature group
featureGroup.addLayer(e.layer);
});
// on click, clear all layers
document.getElementById('delete').onclick = function(e) {
featureGroup.clearLayers();
}
document.getElementById('export').onclick = function(e) {
// Extract GeoJson from featureGroup
var data = featureGroup.toGeoJSON();
// Stringify the GeoJson
var convertedData = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(data));
// Create export
document.getElementById('export').setAttribute('href', 'data:' + convertedData);
document.getElementById('export').setAttribute('download', 'data.geojson');
}
// Add base layers
L.control.layers(basemaps, overlaymaps, {
collapsed: true
}).addTo(map);
// Fit to overlay bounds (SW and NE points with (lat, lon))
map.fitBounds([
[-18.36827062251916, -52.6871074784942],
[-18.35270287637126, -52.7014028427423]
]);
</script>
</body>
</html>
main.py
from PyQt5 import QtWebEngineWidgets, QtWidgets, QtCore
class WebEnginePage(QtWebEngineWidgets.QWebEnginePage):
def __init__(self, *args, **kwargs):
QtWebEngineWidgets.QWebEnginePage.__init__(self, *args, **kwargs)
self.profile().downloadRequested.connect(self.on_downloadRequested)
#QtCore.pyqtSlot(QtWebEngineWidgets.QWebEngineDownloadItem)
def on_downloadRequested(self, download):
old_path = download.path()
suffix = QtCore.QFileInfo(old_path).suffix()
path, _ = QtWidgets.QFileDialog.getSaveFileName(self.view(), "Save File", old_path, "*."+suffix)
if path:
download.setPath(path)
download.accept()
if __name__ == '__main__':
import sys
sys.argv.append("--remote-debugging-port=8000")
sys.argv.append("--disable-web-security")
app = QtWidgets.QApplication(sys.argv)
view = QtWebEngineWidgets.QWebEngineView()
page = WebEnginePage(view)
view.setPage(page)
path = QtCore.QDir.current().filePath("index.html")
view.load(QtCore.QUrl.fromLocalFile(path))
view.show()
sys.exit(app.exec_())
In your case:
self.MainWindow.webMapViewer = QtWebEngineWidgets.QWebEngineView()
self.MainWindow.webPageLayout.addWidget(self.MainWindow.webMapViewer)
page = WebEnginePage(self.MainWindow.webMapViewer) # create page
self.MainWindow.webMapViewer.setPage(page) # set page
self.html_path = os.path.split(os.path.abspath(__file__))[0] + r'/html/test.html'
self.MainWindow.webMapViewer.load(QtCore.QUrl().fromLocalFile(self.html_path))
Plus:
If you want to set a defined route use the following:
#QtCore.pyqtSlot(QtWebEngineWidgets.QWebEngineDownloadItem)
def on_downloadRequested(self, download):
directory = "/path/of/directory"
filename = QtCore.QFileInfo(download.path()).fileName()
download.setPath(QtCore.QDir(directory).filePath(filename))
download.accept()