通过Powershell上载HTTP文件
我尝试在Fritz上通过powershell自动上传文件!但它不起作用。 我通过internet explorer登录到它通过Powershell上载HTTP文件,powershell,http,internet-explorer,Powershell,Http,Internet Explorer,我尝试在Fritz上通过powershell自动上传文件!但它不起作用。 我通过internet explorer登录到它 $ie = New-Object -com InternetExplorer.Application $ie.visible=$true $ie.Navigate("192.168.178.1/") do {sleep 1} until (-not ($ie.Busy)) $ie.document.getElementById("uiPass").value = "pas
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.Navigate("192.168.178.1/")
do {sleep 1} until (-not ($ie.Busy))
$ie.document.getElementById("uiPass").value = "pass"
$ie.Document.getElementById("submitLoginBtn").click()
do {sleep 1} until (-not ($ie.Busy))
$ie.Document.getElementsByTagName['uiImport'].value=Get-Content "myfile" -Raw
我的问题是,我真的不知道uiImport的属性必须是什么。这是我的文件应该以表单上传的地方,但是Powershell一直说它找不到这个属性
$ie.Document.getElementsByTagName['uiImport'].value=获取内容
“myfile”-原始
请尝试使用F12开发者工具检查网页资源,网页是否包含“uiImport”自定义标记
在我看来,“uiImport”可能是输入元素Name属性,而不是标记名。如果是这种情况,可以使用Document.getElementsByName()方法查找输入文本。然后,设置值
示例代码如下:
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.Navigate("<web page url>")
do {sleep 1} until (-not ($ie.Busy))
$elements = $ie.document.getElementsByName("files")
$elements[0].value ="file path"
$uploadtext = $ie.document.getElementsByName("files") | ?{ $_.Id -eq 'txtupload'}
$uploadtext.value ="hello world"
$downloadtext = $ie.document.getElementsByName("files") | where{ $_.Id -eq 'txtdownload'}
$downloadtext.value ="hi"
$uploadtext = $ie.document.getElementsByName("files") | ?{ $_.Id -eq 'txtupload'}
$uploadtext.value ="hello world"
$downloadtext = $ie.document.getElementsByName("files") | where{ $_.Id -eq 'txtdownload'}
$downloadtext.value ="hi"