如何从文件中提取

时间:2017-03-06 16:49:44

标签: html powershell extract

我有一个文件“C:\ temp \ Leather Sofas \ $ line.txt”我需要从这个文件中检索一个特定的字符串“https://d9zprmkgswf02.cloudfront.net/m/12b5900a217677ec/SwatchRangeMediumLandscape-SWATCH_AMX01_BAXTER2_NEW-ENDURANCE-MUSHROOM-D-BROWN-CTRST.jpg

我该怎么做?我目前有

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"      

我可以从哪里离开?

0 个答案:

没有答案