use*_*341 5 html javascript css powershell jquery
如何在powershell中打开网页并向下滚动。
实际上,我正在制作一个脚本,它会自行生成网络报告并给我一个我想要的屏幕截图。我可以打开网页并使用我的脚本开始测试,但我希望我的脚本向下滚动以便可以获取正确的屏幕截图。请帮忙。
确切地说,我希望我的脚本打开一个名为 testmy.net 的网站并进行网络报告。我只想截取报告的屏幕截图并裁剪其他所有内容。我真的很感激任何帮助。
Q) 如何在 PS 中向下滚动网页?我打开网站,我想向下滚动?
问) 如何只截取特定事物的屏幕截图?(经过一番研究,我得到了一些可以截取整个桌面截图的部分)
我附上了我需要的确切东西的截图。

脚本从这里开始:
$ie = new-object -comobject InternetExplorer.Application -property `
@{navigate2="http://testmy.net/SmarTest/combinedAuto"; visible = $true}
# Wait for the page to finish loading
$ie.fullscreen = $true
do {sleep 5} until (-not ($ie.Busy))
# Take A ScreenShot (Script taken from Stackflow)
[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save($path)
$graphics.Dispose()
$bmp.Dispose()
}
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\screenshot.png"
Run Code Online (Sandbox Code Playgroud)
我认为你正在寻找非常快速和肮脏的东西。如果这是真的,并且您不介意难看,请尝试使用 SendKeys。
$ie = new-object -comobject InternetExplorer.Application -property `
@{navigate2="http://testmy.net/SmarTest/combinedAuto"; visible = $true}
# Wait for the page to finish loading
$ie.fullscreen = $true
do {sleep 5} until (-not ($ie.Busy))
[System.Windows.Forms.Cursor]::Position = New-Object system.drawing.point(700,700)
[System.Windows.Forms.SendKeys]::SendWait({DOWN 10})
# Take A ScreenShot (Script taken from Stackflow)
[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save($path)
$graphics.Dispose()
$bmp.Dispose()
}
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\tmp\screenshot.png"
Run Code Online (Sandbox Code Playgroud)
继续调整您发送的向下箭头的数量,直到它正确为止 - 因此请进行编辑{DOWN 10}。
注意: Chirishman 说你需要在
DOWN 10--周围有两个花括号{{DOWN 10}}。在撰写本文时,上面的版本几乎可以肯定在我的盒子上逐字运行,但是 ymmv。
然而,担心您会遇到足够多的时间问题,最终您会返回并使用其他工具。这些你必须拿多少?
请注意,我在测试时确实将 URL 更改为 espn.com。不确定你的情况如何——速度测试?似乎加载了大约三个不同的页面。
| 归档时间: |
|
| 查看次数: |
5054 次 |
| 最近记录: |