【问题标题】:How can I make a working power shell script to fill forms on web pages?如何制作有效的 PowerShell 脚本来填写网页上的表单?
【发布时间】:2020-10-24 19:14:33
【问题描述】:

我正在尝试获取我找到的这个 powershell 代码,以登录到我的路由器登录页面,但 powershell 给我一个错误提示

  • $Form |获取会员
  •     ~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
    • FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand

这里是代码

 # 发现所有要使用的页面/表单和元素

    $url = 'http://192.168.8.1/#/login'
    ($FormElements = Invoke-WebRequest -Uri $url -SessionVariable fe)
    ($Form = $FormElements.Forms[0]) |格式列表-强制
    $表格 |获取会员
    $Form.Fields

    # 与网站页面交互

    $password = '我的密码'
    $loginUrl = 'http://192.168.8.1/#/login'

    $ie = New-Object -com internetexplorer.application
    $ie.visible = $true
    $ie.navigate($loginUrl)

    while ($ie.Busy -eq $true) { 开始睡眠 -Seconds 1 }

    ($ie.document.getElementById('gl-input loginInput') |
    选择 -first 1).value = $password
    开始-睡眠-秒 1

    $ie.Document.getElementsByName('new-password').Item().Click();
    开始-睡眠-秒 1

【问题讨论】:

    标签: forms powershell autocomplete element


    【解决方案1】:

    你必须:

    1. 使用 Windows PowerShell,不使用 PowerShell (v7.0.x) 或 PowerShell Core (v6.x.x)。
    2. 在使用此脚本之前初始化 Internet Explorer。
    3. 编写您自己的脚本。这个脚本是......它有很多像$Form | Get-Member这样的无用代码。看看here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-31
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2010-12-06
      • 1970-01-01
      相关资源
      最近更新 更多