powershell - website scraping
If I run the following:
$nzpost = invoke-webrequest -uri https://nzpost.co.nz/tools/address-p...inder/address/[somenumber]/1 long street highbury palmerston north rd1 ($nzpost.inputfields.value -split '\n')[1] ... i get the resolved address including the postcode (assuming a valid address). If i had a csv file like the following: address1, address2, city, rural 1 long street, highbury, palmerston north, rd1 1 short road, awapuni, palmerston north, rd1 (eg, $csvfile = import-csv -path 'c:\addresses.csv' How would i do a scrape for-each of the csv file lines? [somenumber] seems to be a static random that's re-usable. |
https://sharepoint.fpweb.net/sharepo...ith-csv-files/
has exactly what you're after. I googled for "powershell csv file" |
Or a slightly different way of doing the same:
https://stackoverflow.com/questions/...esponding-data |
I'm ok with the handling of the csv file (i believe), just not the syntax on how to call the invoke-webrequest of the for-each.
for example Import-Csv -Path 'C:\file.csv' | foreach { -join ($_.Address3,' ', $_.Suburb,' ',$_.Town,' ',$_.Rural ) } outputs the query i want and i want to run that against invoke-webrequest -uri https://www.nzpost.co.nz/tools/addre...inder/address/[number]/[{(join query here)}] I'm trying to work out that [{( bit |
right, so:
$query = invoke-webrequest -uri "https://www.nzpost.co.nz/tools/address-postcode-finder/address/[number]/1 long street palmerston north" ($query.inputfields.value -split '\n')[1] can be changed to: ((invoke-webrequest -uri "https://www.nzpost.co.nz/tools/address-postcode-finder/address/[number]/1 long street palmerston north").inputfields.value -split '\n')[1] |
so i got the query working but turns out that number isn't static and is based on the address.
poo. https://www.nzpost.co.nz/tools/addre...inder/address/[number]1 crater lake the moon will always return the same result based on the number :( |
You'll need to register for NZPost's API service
https://www.nzpost.co.nz/business/developer-centre For non commercial it may even be free, I don't know. |
Quote:
|
All times are GMT +13. The time now is 09:56. |
Powered by Trololololooooo
© Copyright NZGames.com 1996-2024
Site paid for by members (love you guys)