zoukankan      html  css  js  c++  java
  • powershell 自动 登陆邮箱

    登陆 Gmail:

    function
    WaitForLoad ($ie) { while ($ie.Busy) { sleep -milliseconds 50 } } ############################################## $ie = New-Object -COM InternetExplorer.Application $ie.Navigate("https://mail.google.com/mail/u/0/#inbox") $ie.Visible = $true WaitForLoad($ie) $email = $ie.Document.getElementByID("Email") $pwd=$ie.Document.getElementByID("Passwd") $btnLogin =$ie.Document.getElementByID("signIn") $email.value="your email address@gmail.com" #需要修改 $pwd.value="passwd" #需要修改
     $btnLogin.click(); 
    ############ write email
    print "exit"
    登陆QQ邮箱:

    function
    WaitForLoad ($ie) { while ($ie.Busy) { sleep -milliseconds 50 } } ############################################## $ie = New-Object -COM InternetExplorer.Application $ie.Navigate("https://mail.qq.com/cgi-bin/loginpage") $ie.Visible = $true WaitForLoad($ie) $email = $ie.Document.getElementByID("uin") $pwd=$ie.Document.getElementByID("p") $btnLogin =$ie.Document.getElementByID("btlogin") # Logo $email.value="your QQ " #需要修改 $pwd.value="passwd" #修改要修改 $btnLogin.click(); # write email $innertext="邮箱首页" $link = $ie.Document.getElementsByTagName("A") | where-object {$_.innerText -eq $innertext} $link.outerHTML
    function:

    Function
    NavigateTo([string] $url, [int] $delayTime = 100) { Write-Verbose "Navigating to $url" $global:ie.Navigate($url) WaitForPage $delayTime } Function WaitForPage([int] $delayTime = 100) { $loaded = $false while ($loaded -eq $false) { [System.Threading.Thread]::Sleep($delayTime) #If the browser is not busy, the page is loaded if (-not $global:ie.Busy) { $loaded = $true } } $global:doc = $global:ie.Document } Function SetElementValueByName($name, $value, [int] $position = 0) { if ($global:doc -eq $null) { Write-Error "Document is null" break } $elements = @($global:doc.getElementsByName($name)) if ($elements.Count -ne 0) { $elements[$position].Value = $value } else { Write-Warning "Couldn't find any element with name ""$name""" } } Function ClickElementByName($name, [int] $position = 0) { if ($global:doc -eq $null) { Write-Error "Document is null" break } $elements = @($global:doc.getElementsByName($name)) if ($elements.Count -ne 0) { $elements[$position].Click() WaitForPage } else { Write-Error "Couldn't find element with name ""$name"" at position ""$position""" break } } Function ClickLinkByInnerText($innertext,[int] $delayTime = 0) { if ($script:doc -eq $null) { Write-Error “Document is null” break } sleep -Seconds $delayTime $link = $script:doc.getElementsByTagName(‘A’) | where-object {$_.innerText -eq $innertext} if ($link -ne $null) { $link.Click() WaitForPage } else { Write-Error “Couldn’t find link with innertext “”$innertext"” break } } #Run the script $verbosePreference = "Continue" $global:ie = New-Object -com "InternetExplorer.Application" $global:ie.Navigate("about:blank") $global:ie.visible = $True NavigateTo "https://mail.qq.com/cgi-bin/loginpage" SetElementValueByName "uin" "userName" SetElementValueByName "p" "pwd" ClickElementByName "btlogin" ClickLinkByInnerText "composebtn"
  • 相关阅读:
    POJ 1321 棋盘问题
    算法导论 4.1 最大子数组问题
    矩阵快速幂
    固定定位
    HTML排版
    CSS笔记2
    HDU 1796 How many integers can you find(容斥原理)
    HDU 2147 kiki's game(博弈经典题)
    HDU 1846 Brave Game(巴什博弈超简单题)
    HDU 4704 Sum(隔板原理+组合数求和公式+费马小定理+快速幂)
  • 原文地址:https://www.cnblogs.com/2zhyi/p/3345141.html
Copyright © 2011-2022 走看看