html - 如何访问从 Invoke-WebRequest 的响应中获取的 HTML 元素的方法和属性?
问题描述
我有一个 my_table 类的表元素。但是,我似乎无法访问它的任何方法或属性。
请注意:
C:\Work> $table = $res.ParsedHtml.body.getElementsByClassName('my_table')
C:\Work> $table | Get-Member | sls className
IHTMLElementCollection getElementsByClassName (string)
string className () {get} {set}
C:\Work> $table.className
C:\Work> $table | Get-Member | sls getAttribute
Variant getAttribute (string, int)
IHTMLDOMAttribute getAttributeNode (string)
IHTMLDOMAttribute2 getAttributeNodeNS (Variant, string)
Variant getAttributeNS (Variant, string)
Variant ie8_getAttribute (string)
IHTMLDOMAttribute2 ie8_getAttributeNode (string)
Variant ie9_getAttribute (string)
IHTMLDOMAttribute2 ie9_getAttributeNode (string)
C:\Work> $table.getAttributeNode('className')
Method invocation failed because [System.__ComObject] does not contain a method named 'getAttributeNode'.
At line:1 char:1
+ $table.getAttributeNode('className')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (getAttributeNode:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
C:\Work>
我究竟做错了什么?
解决方案
推荐阅读
- java - OpenPDF - 一个单元格中的多行
- python - 在 Flask 页面上显示的 Matplotlib 创建的热图 SVG 中添加每个框的链接
- python - “IndexError:列表索引超出范围”错误
- r - 从 r 中的数据集中删除尾随的 0 和 1
- python - 从 df 在 Python 中创建特征表
- node.js - 解决 CloudFlare 下自定义域上的服务器请求中断错误
- python - 为什么我的 MongoDB 查询比 python 慢?
- if-statement - 在 Rust 中使用 if 语句时的不同函数类型
- python - 如何让 django 表单接受具有初始值的禁用表单
- python-3.x - Pystan 安装成功但无法编译