Excluding certain entries from search results

Hello 1Hackers,

I always comeback here to look for solutions whenever I’m stuck online & this community never disappoints.:smile:

Please help me solve this. I want search results of (say) only Zomato keyword in the link shared below & at the same time I want to exclude any entries that has swiggy in search result. How can we make it Possible?

1 Like

What exactly do you want the search result to show?

Put it in search engine:
site:olx.in zomato -swiggy

All search results of Zomato but without the keyword swiggy in it & also what if I want to exclude one more keyword along with swiggy?

Olx’s search engine doesn’t have any options or shortcuts to do that.

Exactly. So how can we achieve it? Is it possible to add something In URL which leads us to our desired results?

I quickly wrote a script which might fulfill your need somewhat

const ulElement = document.getElementsByClassName('rl3f9 _3mXOU')[0];
liElements = ulElement.querySelectorAll('li');
liElements.forEach((item) => {
    const itemTitle = item.querySelector('._2tW1I');
    if(itemTitle) {
        const titleText = itemTitle.textContent.toLowerCase();
        const includeWords = ['apple'];
        const excludeWords = ['philips'];
        let result = excludeWords.some(word => titleText.includes(word))
        if(result)  { return }
        result = includeWords.some(word => titleText.includes(word))
        if(result)  { console.log(itemTitle.textContent); }
    }
})

Update adding this will also remove the node you don’t want

let result = excludeWords.some(word => titleText.includes(word))
if(result)  {
    item.remove()
    return 
}

I have not test if the script works properly so if some error come pm me.

Appreciate your hard work. I haven’t tested either. Actually I missed to mention that I want this filteration to happen on my mobile. Can you help?

If you are using chrome, execute that script and save that page as a link in a txt file or just close it and then reopen that page from chrome on your mobile. Or better yet send that page to your mobile by clicking →
image
and then scan it on your phone.