HTML to Text

Welcome Forums General PowerShell Q&A HTML to Text

This topic contains 1 reply, has 2 voices, and was last updated by

3 years ago.

  • Author
  • #38640

    Topics: 13
    Replies: 21
    Points: 0
    Rank: Member

    Hi All,

    Please help
    how to convert html text to plain text.

  • #38650

    Topics: 15
    Replies: 41
    Points: 21
    Rank: Member

    Hi Vishal,

    There are quite a few conversion cmdlets but the variation in the structure of HTML doesn't allow this to be converted so eaily.

    CommandType     Name
    -----------     ----
    Function        ConvertFrom-SddlString
    Cmdlet          ConvertFrom-Csv
    Cmdlet          ConvertFrom-Json
    Cmdlet          ConvertFrom-SecureString
    Cmdlet          ConvertFrom-String
    Cmdlet          ConvertFrom-StringData
    Cmdlet          Convert-Path
    Cmdlet          Convert-String
    Cmdlet          ConvertTo-Csv
    Cmdlet          ConvertTo-Html
    Cmdlet          ConvertTo-Json
    Cmdlet          ConvertTo-SecureString
    Cmdlet          ConvertTo-TpmOwnerAuth
    Cmdlet          ConvertTo-Xml

    You can scrape the HTML from web sites and then parse it for what you need.

    $web = Invoke-WebRequest -Uri ''
    # Have a look at what comes back then pick out what you want.

    To extract content for you could focus on anchor tags which begin with 'a'

    $text = ($web.ParsedHtml.getElementsByTagName('a') | Where{$_.className -eq 'bbp-forum-title'}).innerText
    DSC (Desired State Configuration)
    PowerShell Q&A
    Web Site Feedback & Assistance
    PowerShell Summit
    Jobs and Industry
    PowerShell Help Authoring
    DSC Script resource erroring out on function name from module
    Get current logged on user (console or RDP) while running under alt credentials
    Win32_Printer delete method
    HTML to Text
    Pester Question
    Expand property using hash table and PSObject
    is it possible to use send-mailmessage to send calendar items?
    Get-WMIObject Win32_LogicalDisk returns disk size of 0 sporadically
    Pin items to Task bar for Default Profile
    How do you use DSC to [declaratively] change the drive letter of the CDROM?

    One last pointer, the protocol for using tags is to use the topics on which your question is based on rather than adding our PowerShell heroes names.


The topic ‘HTML to Text’ is closed to new replies.