• EnglishSpanishGermanFrenchPolishChinese (Traditional)


EnglishSpanishGermanFrenchPolishChinese (Traditional)

Operating systems, scripting, PowerShell and security

Operating systems, software development, scripting, PowerShell tips, network and security

Menú principal
  • Categorías
  • Cursos
  • Libro de PowerShell
  • Lo mejor
  • Lo último
  • Proyectos
  • Contactar
Ir al contenido

Detectar las palabras que están mal escritas en varias noticias de un diario con un comando en Linux y ejecutarlo con WSL (Windows Subsystem for Linux) desde PowerShell

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Descargar el fichero RSS con las noticias
$web = (Invoke-WebRequest "https://rss.elconfidencial.com/espana/").content
 
# Convertir para ver las palabras con acentos
$utf8 = [System.Text.Encoding]::GetEncoding(65001)
$iso88591 = [System.Text.Encoding]::GetEncoding(28591) #ISO 8859-1 ,Latin-1
$wrong_bytes = $utf8.GetBytes($web)
$right_bytes = [System.Text.Encoding]::Convert($utf8,$iso88591,$wrong_bytes)
$right_string = $utf8.GetString($right_bytes)
 
# Detectar las palabras que están mal escritas en cada artículo
# https://www.jesusninoc.com/2018/06/17/detectar-las-palabras-que-estan-mal-escritas-en-un-articulo-de-un-diario-con-un-comando-en-linux-y-ejecutarlo-con-wsl-windows-subsystem-for-linux-desde-powershell/
$xml = [xml]$right_string
$xml.feed.entry.content.'#cdata-section' | %{
    $_
    $_ | bash -c 'aspell list --encoding iso-8859-1 -d es' | Group-Object | Select-Object Name
}

Publicado el día 29 de junio de 2018

CATEGORÍAS

Bash, PowerShell

ETIQUETAS

aspell, Bash, cdata-section, Group-Object, HTTPS, Invoke-WebRequest, ISO, Jesús Niño, Jesús Niño Camazón, Linux, RSS, Select-Object, System.Text.Encoding, Text.Encoding, UTF8.GetBytes, UTF8.GetString, Windows, WSL, XML

MÁS

  • Ejercicios de seguridad: práctica sobre virus
  • Leer las noticias de un medio de comunicación mediante la voz del Sistema Operativo
  • 11. Gestión del Directorio Activo (nivel intermedio)
  • Extraer las palabras que tengan más de 4 caracteres de un texto mediante Aspell de Linux desde PowerShell con WSL
  • Contar el número de palabras que hay en un libro con PowerShell
  • Descargar un script en Bash almacenado en Github y ejecutarlo con WSL (Windows Subsystem for Linux) desde PowerShell