I'm working on a task, where I need to download a page as HTML. This page is from our website built on Sitecore 10.1.3.
I'm using powershell to achieve this. The page download's fine, but there are console errors for all the JS script files. All these are from Sitecore Media Library.
When I open the view source of the downloaded page and click on any JS reference, the JS file content loads fine.
But in browser console, it shows errors and some Chinese content. These errors are only for JS scripts but not for any CSS even though they are also rendered from sxa theme.
I have tested this with different websites
- https://example-1-page-with-sxa-theme.com - Has issue
- https://example-2-page-with-sxa-theme.com - Has issue
- https://example-3-sitecore-page-with-no-sxa-theme.com - No issue
- https://example-3-non-sitecore-page.com - No issue
Windows powershell script:
cls
$page = Invoke-WebRequest -Uri "https://example-1-page-with-sxa-theme.com"
$content = $page.Content
$content = $content.Replace('="/','="https://example-1-page-with-sxa-theme.com/')
$content | Out-File -FilePath "D:\test.html"