Tuesday, 08 January 2019 14:08

Searching a load of stuff

Written by Sharkis
Rate this item
(0 votes)

I have 174 rows of products to look up prices for, and they're not all available on the same site, so we're Googling.

A Stack Overflow post and some testing shows that the Run window can open a new tab with chrome /newtab URL But, I don't want to open a million tabs, so let's see what else we can do. How about we just do 10 at a time? I don't want to use a bat file, so let's see if we can do it in PowerShell.

A powershell loop looks like this:

for($i=1; $i -lt 175; $i++){
    do the thing
or can we loop this over the file?
foreach($line in gc .\products.txt){
    echo $line

ok good.

let's try running chrome

$chrome = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
&$chrome /newtab tattoodoctor.com

cool. before we let 'er rip, let's try some program control:

$chrome = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
foreach($line in gc .\products.csv){
    &$chrome /newtab "https://google.com/search?tbm=shop&q=$line"
    if ($i % 10 -eq 0){
        Read-Host "Press Enter to continue..."
fuckin' nailed it

Read 214 times Last modified on Tuesday, 08 January 2019 15:22
More in this category: « Bash and fax machines