C# HtmlDocument 中的 Javascript GetElementByName
我正在编写一个网络自动化程序,它根据存储的数据填写冗长的在线表格,然后通知用户结果。我正在自动化的网站为其所有对象命名,但不使用 id 标签。是否有类似 HtmlDocument.GetElementById 之类的东西可以与名称标签一起使用?我认为 GetElementsByTagName 不对。它不返回特定元素,而是生成一个数组。
I am writing a web automation that fills out lengthy online forms based on stored data and then notifies the user of the results. The website that I am automating names all of it's objects, but does not use the id tag. Is there something like HtmlDocument.GetElementById that works with the name tag? I don't think GetElementsByTagName is right. It doesn't return the specific element, but instead generates an array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以迭代
GetElementsByTagName
返回的元素并检查它们的name
属性(与标记名称不同)。GetElementByTagName
获取具有相同元素名称的所有元素(因此对于图像,标签名称为img
)。You can iterate over the elements returned by
GetElementsByTagName
and check theirname
attribute (which is not the same as a tag name).GetElementByTagName
gets all elements that have the same element name (so for images, the tag name isimg
).