Skip to content

Invoke-WebRequest Example 1 No InputFields Returned #10829

Closed

Description

Type of issue

Outdated article

Feedback

The code mentioned in the first example works correctly, but the returned InputFields from Bing do not contain any names matching "* Value". I think this is because Bing changed how the input fields are loaded / presented on the page.

When navigating directly to the link, those fields do exist. When I look through the $Response HTML, I can not find the input fields that were present on the web page.

Code used:

$Response = Invoke-WebRequest -URI https://www.bing.com/search?q=how+many+feet+in+a+mile
$Response.InputFields | Where-Object {
    $_.name -like "* Value*"
} | Select-Object Name, Value

Expected Response:

name       value
----       -----
From Value 1
To Value   5280

Actual Response:
None

Screenshot of debugger $Response object:
image

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Utility/Invoke-WebRequest.md

Author

Sean Wheeler (@sdwheeler)

Document Id

b2e7e015-35b9-897c-3581-ad982240c97c

Activity

  1. changed the title [-]Example 1 Broken[/-] [+]Invoke-WebRequest Example 1 No InputFields Returned[/+] on Jan 25, 2024
  2. sdwheeler commented on Jan 25, 2024

    @sdwheeler
    Contributor

    You were looking at the documentation for PowerShell 7.4 but it looks like you were running the example in Windows PowerShell 5.1.

    The correct way to run it in Windows PowerShell 5.1 is:

    $Response = Invoke-WebRequest -UseBasicParsing -URI https://www.bing.com/search?q=how+many+feet+in+a+mile 
    $Response.InputFields | Where-Object {
        $_.name -like "* Value*"
    } | Select-Object Name, Value

    Output:

    name       value
    ----       -----
    From Value 1
    To Value   5280
    
  3. beingmerry commented on Jan 25, 2024

    @beingmerry
    Author

    Got it. Thanks!

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

Metadata

Metadata

Labels

area-utilityArea - Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions