Skip to content

Invoke-Webrequest is missing some properties, like .ParsedHtml and .AllElements #2867

Description

@ilgrank

Hello Everyone
PsCore 6.x's Invoke-Webrequest is missing on the most 'loved' Ps 'classic' features, ie the ability to parse web pages and turn them into explorable objects.

Steps to reproduce

$test=invoke-webrequest -url http://www.github.com

Expected behavior

$test.ParsedHtml
$test.AllElements
(amont others) are missing:

Microsoft Powershell :
psclassic

Core Poweshell:
pscore

Actual behavior

these properties are missing

Environment data

CLRVersion
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.3
PSEdition Core
WSManStackVersion 3.0
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.13
PSVersion 6.0.0-alpha
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}

I have hope to have web parsing capabilities in PSCore!
Thanks everyone!

Activity

  1. added
    WG-Cmdletsgeneral cmdlet issues
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on Dec 10, 2016
  2. BrucePay commented on Feb 18, 2017

    @BrucePay
    Collaborator

    Joey Aiello (@joeyaiello) FYI: Full PowerShell essentially uses Internet Explorer to do the HTML parsing. This is likely to be problematic to replicate on .NET core.

  3. added this to the milestone on Feb 28, 2017
  4. joeyaiello commented on Mar 1, 2017

    @joeyaiello
    Contributor

    Bruce Payette (@BrucePay) I'd still like to investigate after we look at whatever ends up shipping .NET Standard 2.0

  5. modified the milestones: , 6.0.0-beta1 on Mar 15, 2017
  6. jakerobinson commented on May 3, 2017

    @jakerobinson

    What's the best alternative if this is low priority? Any low effort workarounds for parsing HTML in core?

  7. SteveL-MSFT commented on May 3, 2017

    @SteveL-MSFT
    Member

    .Net Std 2.0 doesn't solve this. There is another issue where we discussed the need to leverage an OSS html parser rather than rely on a web browser being available (#2867), doing that work should also resolve this one.

  8. modified the milestones: , on May 15, 2017
  9. 37 remaining items

  10. iSazonov commented on Mar 14, 2020

    @iSazonov
    Collaborator

    Since new Microsoft Edge is based on Chromium we could discover Chromium engine on system and utilize the API.

  11. jdelforno commented on Jul 28, 2020

    @jdelforno

    Ran into this today as well.

    Name Value


    PSVersion 7.0.3
    PSEdition Core
    GitCommitId 7.0.3
    OS Microsoft Windows 10.0.19041
    Platform Win32NT
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1
    WSManStackVersion 3.0`

  12. fMichaleczek commented on Jul 28, 2020

    @fMichaleczek
    Contributor

    I think Tsubasa (@kamome283) module is a better way with AngleSharp than try to communicate with an external process.
    https://github.com/kamome283/AngleParse

    GitHub
    HTML parsing and processing tool for PowerShell. Contribute to kamome283/AngleParse development by creating an account on GitHub.
  13. removed this from the Future milestone on Oct 19, 2020
  14. added
    Resolution-ExternalThe issue is caused by external component(s).
    and removed
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on Oct 19, 2020
  15. SteveL-MSFT commented on Oct 19, 2020

    @SteveL-MSFT
    Member

    Seems that the community has helped fill in this gap with modules on PowerShellGallery to specifically handle parsing html.

  16. francisco-lafe commented on Sep 13, 2021

    @francisco-lafe

    So, simply put, this Invoke-WebRequest cmdlet is not compatible for PS7 if I developed a script on PS5?
    Given that all the online information is mixed and you never know when they're talking about PS5 or PS7.

  17. wisemoth commented on Sep 13, 2021

    @wisemoth

    Given that all the online information is mixed and you never know when they're talking about PS5 or PS7.

    To be fair the documentation hosted at Microsoft makes it very easy to choose between (Windows) Powershell 5.1 and (say) Powershell 7.1; for example:

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.1
    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1

    There you can (for example) see different text for -UseBasicParsing

    The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements. This cmdlet was introduced in PowerShell 3.0. Beginning in PowerShell 7.0, Invoke-WebRequest supports proxy configuration defined by environment variables. See the Notes section of this article. Important The examples in this article reference hosts in the contoso.com domain. This is a fictitious domain used by Microsoft for examples. The examples are designed to show how to use the cmdlets. However, since the contoso.com sites do not exist, the examples do not work. Adapt the examples to hosts in your environment.
    The Invoke-WebRequest cmdlet sends HTTP, HTTPS, FTP, and FILE requests to a web page or web service. It parses the response and returns collections of forms, links, images, and other significant HTML elements. This cmdlet was introduced in Windows PowerShell 3.0. Note By default, script code in the web page may be run when the page is being parsed to populate the ParsedHtml property. Use the -UseBasicParsing switch to suppress this. Important The examples in this article reference hosts in the contoso.com domain. This is a fictitious domain used by Microsoft for examples. The examples are designed to show how to use the cmdlets. However, since the contoso.com sites do not exist, the examples do not work. Adapt the examples to hosts in your environment.
  18. serialhex commented on Dec 12, 2021

    @serialhex

    wisemoth did you intentionally make 2 links to the same thing for invoke-webrequest? because both of those links point to the same URL and give the same information (for PowerShell 7,2). If you're trying to say that the information is not mixed then doing this disproves your point...

  19. francisco-lafe commented on Dec 13, 2021

    @francisco-lafe

    wisemoth did you intentionally make 2 links to the same thing for invoke-webrequest? because both of those links point to the same URL and give the same information (for PowerShell 7,2). If you're trying to say that the information is not mixed then doing this disproves your point...

    You're using the link previews created by github....

  20. serialhex commented on Dec 13, 2021

    @serialhex

    Huh, i guess I am... I sit corrected. Why isn't the preview of the complete link? ehhh... automated technology failing us all again! Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-ExternalThe issue is caused by external component(s).WG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions