如何选择来自 Invoke-WebRequest 的元素

如何选择来自 Invoke-WebRequest 的元素

我有以下请求:

 $request = Invoke-WebRequest -Uri "https://........" `
 $requestEncode = $request.ParsedHtml.documentElement.innerHtml
 $requestEncode

这给了我回报:

// Toggle visible state of elements function replaceHeroContentWithResults() { const
 results = document.querySelector(".hero__results"); const heroContent = document.qu
erySelector(".hero__content"); results.classList.toggle("is-hidden"); heroContent.cl
assList.toggle("is-hidden"); } // Display the results of the seach function renderRe
sultsPartial() { const results = document.querySelector(".hero__results"); results.i
nnerHTML = "<SECTION class='\"results' dark-theme\?>\n <HEADER class='\"results__hea
der\"'>\n 
<H2 class='\"results__title\"'>Search Results&lt;\/h2&gt;\n 
<DIV class='\"results__nav\"'>\n 
<P class='\"results__subtitle\"'>Your search contained one ingredient known to promo
te the growth of malassezia.&lt;\/p&gt;\n &lt;\/div&gt;\n &lt;\/header&gt;\n\n 
<TABLE class='\"results__table\"'>\n 
<TBODY>\n 
<TR>\n 
<TH scope='\"col\"'>ingredient name&lt;\/th&gt;\n 
<TH scope='\"col\"'>category&lt;\/th&gt;\n &lt;\/tr&gt;\n\n 
<TR>\n 
<TH scope='\"row\"' data-label='\"name\"'>\n <SPAN class='\"type-of' lipids\?>\n ole
a europaea (olive) fruit oil\n &lt;\/span&gt;\n &lt;\/th&gt;\n </SPAN>
<TD data-label='\"category\"'>\n <SPAN class='\"type-of' lipids\?>\n Lipids\n &lt;\/
span&gt;\n &lt;\/td&gt;\n &lt;\/tr&gt;\n &lt;\/tbody&gt;\n &lt;\/table&gt;\n\n <SECT
ION class='\"results__comments\"'>\n &lt;\/section&gt;\n\n <SECTION class='\"results
__footer\"'>\n <A href='\"/search-again\"' data-remote='\"true\"'>Search again&lt;\/
a&gt;\n &lt;\/section&gt;\n&lt;\/section&gt;\n"; } // Reset search form function res
etSearchForm() { const search = document.querySelector(".jsSearchForm"); search.rese
t(); } replaceHeroContentWithResults(); resetSearchForm(); renderResultsPartial(); <
/A></SPAN></TR></TBODY></P></DIV></H2>

它没有被解析,因为当我输入-UseBasicParsing时它不起作用,我的问题是如何从该 html 中选择一个元素,例如“成分名称”

相关内容