Powershell WebRequest uncorrect results when filtering Boursorama

I’m trying to get data from the boursorama website, but when I send the request with parameters, the result is incorrect.

The URL is the following : Turbo bourse, analyses turbos, turbo call/put et palmarès- Boursorama

My goal is to get a list of products which are in the webpart called “Rechercher des Turbos, Call ou Put”.

I would like to filter with a “sous-jacents” or to filter the MidPrice by low to high for example, but it doesn’t work.

Following is the Powershell request for finding a “sous-jacents”:

$r = Invoke-WebRequest -Uri 'http://www.boursorama.com/bourse/derives/turbos/?ssjacent=ACCOR'
$r.ParsedHtml.getElementsByTagName('td') |
  Where-Object { $_.classname -eq 'tdv-libelle_ssjct_warrant' } |
  Select-Object -Property innerText

Following is the Powershell request for filtering per “MidPrice” :

$r = Invoke-WebRequest -Uri 'http://www.boursorama.com/bourse/derives/turbos/?type_ssjacent=Actions&strategie=C&type_derive=C&turbo=true&sort=last%20ASC&page=2'
$r.ParsedHtml.getElementsByTagName('td') |
  Where-Object { $_.classname -eq 'tdv-isin' } |
  Select-Object -Property innerText

Thank you for your help :slight_smile:

It’s always helpful if you can be more specific than “doesn’t work,” since we can’t always try your code ;).

That said, I’ve found that DOM-based filtering like this rarely works well. PowerShell is using an unholy combination of .NET and ancient COM (for Internet Explorer), and the alliance between those is shaky at best. PowerShell’s just not great at manipulating HTML, unless it’s XHTML and you treat it as an XML document instead. Then you’re in pure .NET and it works pretty well.

I would probably switch tactics and just go after the raw HTML using a capturing regular expression. That’s an enormous learning curve if you’ve not done them before, but it’s pure .NET and it works a lot better.

Ok, here is what my “doesn’t work” means :
If you check and open the entire responseText (Raw HTML) with NotePad++, you will see the requested array from line 740 to 851 or between the first tbody and \tbody, that’s the data I’m looking for.
When I request a specific “sous-jacents” (exemple : ACCOR) by sending the parameter in the URL, the data I have in the requested array is not the one “ACCOR” or if I want to sort the data by “MidPrice”, the data is not sorted. Tell me if you need more explanation.

Ok, noted for the inconvenient of Powershell, I also tried with VBS and CURL, but it’s the same.

I never tried .NET but I’m open minded :slight_smile: