0

I have a file "C:\temp\Leather Sofas\$line.txt" I need to retrieve a specific string from this file "https://d9zprmkgswf02.cloudfront.net/m/12b5900a217677ec/SwatchRangeMediumLandscape-SWATCH_AMX01_BAXTER2_NEW-ENDURANCE-MUSHROOM-D-BROWN-CTRST.jpg"

How would I go about this? I currently have

foreach ($line in Get-Content C:\temp\Results.txt) {
    try {
        Invoke-WebRequest "https://www.scs.co.uk/la-z-boy-temptation-3-seater-power-recliner-sofa/$line.html" |
            Set-Content "C:\temp\Leather Sofas\$line.txt"
    } catch {
        $_.Exception.Response.StatusCode.Value__
    }

    $A = Select-String -Path "C:\temp\Leather Sofas\$line.txt" -Pattern 'ul class="product-select__list' -Context 1, 1 |
         Set-Content "C:\temp\Leather Sofas\$line list.txt"
    $B = Select-String -Path "C:\temp\Leather Sofas\$line.txt" -Pattern 'class="product-select__item' -Context 0, 0 |
         Set-Content "C:\temp\Leather Sofas\$line item.txt"
    $C = Select-String -Path "C:\temp\Leather Sofas\$line.txt" -Pattern 'class="product-select__link' -Context 0, 0 |
         Set-Content "C:\temp\Leather Sofas\$line Link.txt"
    $D = Select-String -Path "C:\temp\Leather Sofas\$line.txt" -Pattern 'product-select__img' -Context 0, 0 |
         Set-Content "C:\temp\Leather Sofas\$line Image.txt"      

Where can I go from here?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 2
    What specific string? – Bill_Stewart Mar 06 '17 at 17:41
  • 1
    Did nobody ever tell you that [parsing HTML with regex](http://stackoverflow.com/a/1732454/1630171) is the path to the dark side? The returned response object should already provide you with the parsed HTML content (via a property that, perhaps surprisingly, was named `ParsedHtml`). Proceed from there. – Ansgar Wiechers Mar 06 '17 at 20:51

0 Answers0