Holen Sie das Beste aus den Nachrichten im Internet heraus
Inspiriert von dem Artikel Warum ich immer noch RSS benutze
Ich selbst benutze sehr aktiv das Nachrichtenformat, das ich mit der Community teilen möchte.
Es wird Screenshots und vielleicht eine etwas überflüssige Erklärung geben.
Es wird folgende Teile geben:
Teil 1 :
Welche Informationen konsumiere ich normalerweise durch Nachrichten?
Leseprogramme (RSS-Aggregatoren) - was ich persönlich benutze;
RSS- und Atom-Formate, wie sie von Programmen auf dem lokalen Computer verarbeitet werden können;
2:
(zapier, ifttt);
3:
- .
1
, , , , ( , !). , RSS. . RSS. , RSS! , , RSS .
. , 1.
(rss-)
, . , - , Apple .
- , .. - « » . .
JetBrains , , :
,
- .
RSS Atom,
, - xml-. RSS ( , ). :
- -
<pubDate>Sun, 28 May 2017 09:00:00 GMT</pubDate>
,
- , RSS, ( ). . , , .
RSS Google - Atom, .
, , curl, wget (- ?) Power-shell.
, , Windows 10 curl « » . .
Curl:
chcp 65001
curl ^
--header "user-agent: cURL automated task" ^
--output "%TEMP%\updates.xml" ^
"https://news.webits.1c.ru/news/Updates/atom"
, curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - .
5 .
BOM, . - .
Power-shell:
# file: Get-News-001.ps1
Clear-Host
$webClient = New-Object Net.WebClient
$webClient.UseDefaultCredentials = $true
$webClient.Proxy.Credentials = $webClient.Credentials
$webClient.Headers.Add("user-agent", "PowerShell automated task")
# , - , BOM,
# DownloadString .
# UTF8
$newsData = $webClient.DownloadData("https://news.webits.1c.ru/news/Updates/atom")
Write-Host ([System.Text.Encoding]::UTF8).GetString($newsData)
, power-shell . IDE, , -ExecutionPolicy=RemoteSigned
powershell -file "Get-News-001.ps1" -ExecutionPolicy=RemoteSigned
? . - xml, - ? , - ?
1 « = »
« = »
:
# file: Get-News-002.ps1
Clear-Host
# ,
$CategoryProducts = @(
# "=1: ", # !
"= " # !
)
$CategoryNewsTypes = @(
" = "
)
$webClient = New-Object Net.WebClient
$webClient.UseDefaultCredentials = $true
$webClient.Proxy.Credentials = $webClient.Credentials
$webClient.Headers.Add("user-agent", "PowerShell automated task")
# .. BOM, .
$newsData = $webClient.DownloadData("https://news.webits.1c.ru/news/Updates/atom")
[xml]$news = ([System.Text.Encoding]::UTF8).GetString($newsData)
#[xml]$news = Get-Content -Encoding UTF8 -LiteralPath "$($env:TEMP)\updates.xml"
for($c1=0;$c1 -lt $news.feed.entry.Count;$c1++){
#
$entry = $news.feed.entry[$c1]
$ProductName = ""
$bFoundProduct = $false
$bFoundNewsType = $false
for($c2=0;$c2 -lt $entry.category.Count;$c2++){
#
$CategoryProducts | ForEach-Object {
if($entry.category[$c2].term -eq $_){
$ProductName = $entry.category[$c2].term
$bFoundProduct = $true
}
}
$CategoryNewsTypes | ForEach-Object {
if($entry.category[$c2].term -eq $_){
$bFoundNewsType = $true
}
}
}
if ($bFoundProduct -and $bFoundNewsType) {
Write-Host (" . : {0}, : {1}" -f ($entry.id, $entry.title))
}
}
. , ? , .
, - entry.id
- .
# file: Get-News-003.ps1
Clear-Host
# email.
$sendedEmailsPath = "$($env:TEMP)\sended.csv" # !
if(Test-Path $sendedEmailsPath){
#
} else {
# -
Add-Content -LiteralPath $sendedEmailsPath -Encoding UTF8 -Force -Value ""
}
$sendedEmails = Get-Content -LiteralPath $sendedEmailsPath -Encoding UTF8 -Force
#
$CurrentDate = Get-Date
$CurrentDate_String = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$From = "news_center_tester@mail.ru" # !
$To = "old-coder-75@mail.ru" # !
$EncodingUTF8 = [System.Text.Encoding]::UTF8
$UserName = "news_center_tester" # !
$Password = "*****" # !
$Credential = New-Object -TypeName System.Management.Automation.PSCredential($UserName, (ConvertTo-SecureString $Password -AsPlainText -Force))
$SMTPServer = "smtp.mail.ru" # !
$SMTPPort = 587 # !
# ,
$CategoryProducts = @(
# "=1: ", # !
"= " # !
)
$CategoryNewsTypes = @(
" = "
)
$webClient = New-Object Net.WebClient
$webClient.UseDefaultCredentials = $true
$webClient.Proxy.Credentials = $webClient.Credentials
$webClient.Headers.Add("user-agent", "PowerShell automated task")
$newsData = $webClient.DownloadData("https://news.webits.1c.ru/news/Updates/atom")
[xml]$news = ([System.Text.Encoding]::UTF8).GetString($newsData)
#[xml]$news = Get-Content -Encoding UTF8 -LiteralPath "$($env:TEMP)\updates.xml"
for($c1=0;$c1 -lt $news.feed.entry.Count;$c1++){
#
$entry = $news.feed.entry[$c1]
$ProductName = ""
$bFoundProduct = $false
$bFoundNewsType = $false
for($c2=0;$c2 -lt $entry.category.Count;$c2++){
#
$CategoryProducts | ForEach-Object {
if($entry.category[$c2].term -eq $_){
$ProductName = $entry.category[$c2].term
$bFoundProduct = $true
}
}
$CategoryNewsTypes | ForEach-Object {
if($entry.category[$c2].term -eq $_){
$bFoundNewsType = $true
}
}
}
if ($bFoundProduct -and $bFoundNewsType) {
Write-Host (" . : {0}, : {1}" -f ($entry.id, $entry.title))
# , email?
# email id - $sendedEmailsPath.
$bEmailWasSent = $false
foreach ($sendedEmail in $sendedEmails) {
if ( $sendedEmail.StartsWith($entry.id) ) {
$bEmailWasSent = $true
break
}
}
# email.
if ($bEmailWasSent -eq $false){
Write-Host " ..."
#
$Subject = $entry.title
$Body = "<h1> </h1>" + `
"<p>" + `
$entry.summary."#cdata-section" + `
"</p>"
Send-MailMessage `
-From $From `
-To $To `
-Body $Body `
-BodyAsHtml `
-Credential $Credential `
-Encoding $EncodingUTF8 `
-SmtpServer $SMTPServer `
-Subject $Subject `
-Priority High `
-UseSsl `
-Port $SMTPPort `
-Verbose
# ,
$LogString = $entry.id + ";" + $CurrentDate_String + ";"
Add-Content -LiteralPath $sendedEmailsPath -Encoding UTF8 -Force -Value $LogString
} else {
Write-Host " ."
}
}
}
. . , 2 . " ". (Win+R) "taskschd.msc
".
:
« 4 » ():
(« »):
powershell.exe . - -file
, « ».
Ein bisschen Tuning - ich mag keine Popups. Und wenn die Aufgabe gemäß dem Zeitplan ausgeführt wird, wird alle 4 Stunden das Skriptausführungsfenster auf dem gesamten Bildschirm angezeigt. Sie können Power-Shell-Code über SilentCMD oder CreateProcessHidden ausführen . Zwar schwört das Antivirus auf Letzteres, aber nicht viel.
Diese Methode zum Überprüfen von Nachrichten hat einen solchen Nachteil: Sie erfordert, dass dieser Computer ständig eingeschaltet wird. Daher werde ich Ihnen in den nächsten Abschnitten erklären, wie Sie das Lesen von Nachrichten mithilfe von Automatisierungsdiensten automatisieren und wie ich Podcasts für mich selbst herunterlade.
Nun, ich hoffe die Informationen waren hilfreich.
Ich habe die Kommentare mit Interesse gelesen.
Ich werde versuchen, den Rest der Kapitel in naher Zukunft zu veröffentlichen.