Technically I had ai help me create this script, but I’ve made the script in python and autohotkey in the past.

When I’m researching an item I look up the current listings and sold listings as well as on eBay’s product research page.

Instead of going to each page and typing in search and then filtering by sold, I made a script which takes a search term and opens up a new window with three tabs with the search already completed for current, sold, and research.

#!/bin/bash

# Join all arguments into a single string
search_term="$*"

# URI-encode the search term
encoded_term=$(printf '%s' "$search_term" | jq -sRr @uri)

# Open Chromium with a new window and search eBay
chromium --new-window "https://www.ebay.com/sch/i.html?_nkw=%24encoded_term" "https://www.ebay.com/sch/i.html?_nkw=%24encoded_term&rt=nc&LH_Sold=1&LH_Complete=1" "https://www.ebay.com/sh/research?marketplace=EBAY-US&keywords=%24encoded_term" &

wait

Edit: added wait command, changed to chromium web browser, added --new-window and put all urls on the same command, changed to & instead of &&

The way this works is that it is placing the search term you enter into the url and just loading the url without having to interact with the search bar on the website at all.

If you look at the url when you search “baked beans” you can see the words “baked beans” in the url: https://www.ebay.com/sch/i.html?_nkw=baked+beans

you can then replace the words with different words and automatically load search results that way. I then created a helper script and bound it to a keyboard shortcut. So now when I press my shortcut combo it opens up a terminal and asks for my search term:

#!/bin/bash

# Clear the screen
clear
echo "eBay Item research"
read -p "Enter search term: " term

# Call your real script
~/search_ebay.sh "$term"

Of course these could be one complete script, but I haven’t bothered to combine them and well it works on my machine. I’d love critique and please share any automatons you’ve created to help your workflow!

  • octoshrimpy@sh.itjust.works
    link
    fedilink
    arrow-up
    4
    ·
    20 days ago

    Welcome to bash! I recommend dropping your code into shellcheck every now and then. Bash is full of footguns, trust me. Instead of screen clear, look up alternate mode for the terminal. It’s super slick.

    Separating the script into two pieces will help you troubleshoot in the future, so even though you could join them, there’s really no need for it. At best I’d make them into functions to keep code clean.

    If you have any questions, feel free to send them my way, bash is my preferred language and I will gladly guide someone. :)

    • PriorityMotif@lemmy.worldOPM
      link
      fedilink
      arrow-up
      2
      ·
      20 days ago

      Holy moley that is a big script! I’m having a hard time finding anything about alternate mode. I would like to find more ways to automate my workflow as listing is the most work in flipping and most people have a “death pile” because listing takes so long. I already have synching syncing photos from my phone to PC because listing from the app takes so long. I haven’t actually been able to use the photos because they render as a solid color in my browser, this might be a browser issue. I might have to use chromium instead. I also created a simple script to open several tabs when I go to print labels and ship because opening multiple bookmarks in librewolf is a lot of clicks so I can now just use a hotkey instead. In the past I created a similar script to search my local stores from closest to farthest when I needed to buy something. Then I could price compare before leaving the house and know exactly what I wanted when I got there.

      Thanks for the input!