[xml]$techspot = iwr https://www.techspot.com/backend.xml $articles = $techspot.getelementsbytagname('item') foreach ($a in $articles){ $link = $a.link $title = $a.title.'#cdata-section' $html = New-Object -ComObject "HTMLFile" $html.IHTMLDocument2_write($a.description.'#cdata-section') $imglink = $html.body.getelementsbytagname('img')[0].src $text = $html.body.innertext [System.Runtime.Interopservices.Marshal]::ReleaseComObject($html)|out-null $a.pubdate = ("<table width='100%'><tr><td style='font-family: Arial, sans-serif;'><a href=$link><img width=200 align=left src=" + $imglink + "></a><center><h3>" + $title + "</h3></center></td></tr></table><table><tr><td style='font-family: Arial, sans-serif;font-size:13;'>" + $text + "</td></tr></table><hr style='border: 2px solid mintcream;'>") } $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $Username = "myemail@gmail.com" $Password = "mypassword" $to = "recipient@somemail.com" $subject = ("Techspot - " + (get-date).tolongdatestring()) $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.body = $articles.pubdate $message.to.add($to) $message.from = $username $message.IsBodyHTML = $true $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); $smtp.EnableSSL = $true $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); $smtp.send($message)
PS C:\Scripts>Write-host "The Best Way To Predict The Future" -foreground white The Best Way To Predict The Future PS C:\Scripts>"is to create it!"|for-each {write-host $_.toupper() -foreground white} IS TO CREATE IT!
Friday, September 22, 2017
PowerShell: Invoke-WebRequest Techspot RSS Feed Emailer
Follow the code below to receive emails from Techspot using their RSS feed:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment