0

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

  1. https://example-1-page-with-sxa-theme.com - Has issue
  2. https://example-2-page-with-sxa-theme.com - Has issue
  3. https://example-3-sitecore-page-with-no-sxa-theme.com - No issue
  4. 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"

enter image description here

enter image description here

1 Answer 1

1

It seems related to encoding. Just try to add encoding parameter equals UTF8 like this while downloading file.

$content | Out-File -FilePath "D:\test.html" -Encoding UTF8

Check this article for further reading - https://stackoverflow.com/questions/12190078/stylesheet-taken-over-replaced-by-chinese-characters

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.