Invoke-WebRequest process stuck in the middle

Welcome Forums General PowerShell Q&A Invoke-WebRequest process stuck in the middle

Viewing 0 reply threads
  • Author
    Posts
    • #258859
      Participant
      Topics: 2
      Replies: 0
      Points: 11
      Rank: Member

      Hi All,

      I am a newbie and making small progress 🙂  I am writing a simple test script to find how many times a specific keyword appears on a given site.  The test example I am taking is from gumtree website – searching for keyword ‘puppy’

      Here is the script that I have got (with someone’s help):

      $count=([regex]::Matches($web.content, “labrador” )).count
      return $count`
      Now the script works fine sometimes, the other times it will freeze while processing the webrequest.  It doesnt move from :

      “Reading response stream… (Number of bytes read: 186743)”

      the number of bytes vary from time to time, but it stays on this for a while and then terminates giving a false much lower count of the keyword.

      What I have tried so far:

      • -UseBasicParsing
      • I also tried dispose() thinking we need to release the resources, to do that I added $count= before the last line, and then tried adding $count.Dispose() however that gives me error — InvalidOperation: Method invocation failed because [System.Int32] does not contain a method named ‘dispose’

      Any help with this is much appreacited.

      • This topic was modified 1 month ago by newbie8479.
Viewing 0 reply threads
  • You must be logged in to reply to this topic.