Repository: searxng/searxng

Issue:
Bug: brave giving invalid links taken from ads
**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
Repository: https://github.com/searxng/searxng
Branch: master
Version: 2023.9.17+b4e0d2eed
<!-- Check if these values are correct -->

**How did you install SearXNG?**
Docker
**What happened?**
Brave engine is returning links such as `http:///a/redirect?click_url=https%3A%2F%2Fwww.wayfair.com%2Fdecor-pillows%2Fsb0%2Fcurtains-drapes-c481844.html%3Frefid%3DBRAVE%26bravecreativeid%3D6260.1%26pageexpansion%3D1&amp;placement_id=03944d2c-31a3-4f56-a854-920a98610edb&amp;creative_instance_id=d956cac0-326d-4d4b-97b6-aefda3900e73&amp;nonce=2bd1308ae44dd76e139a6ab8f6cceec1&amp;sig=1ab592cfc4a296e23eb271ced0292a393cbb746ca99b163a917279aa92c291bf` which obviously don't work

**How To Reproduce**
`!brave air curtains` and look at the Wayfair link

**Expected behavior**
Working links

**Additional context**
On the official site, the only Wayfair link for that result is an ad:

![air curtains](https://github.com/searxng/searxng/assets/1284317/0ccc30e4-114d-4200-8fdf-7e18e2bfa288)

It probably shouldn't be pulling this link at all.

HTML of ad:

```html
<div class="snippet standalone svelte-uqu4ua" id="search-ad" data-placement-id="e4d9be7d-1aab-4a2f-912b-3db783cf7440" data-creative-instance-id="3cce4974-9405-4345-9943-83478601f7f8" data-creative-set-id="a297d173-8f2d-477e-8f19-49124ebb7057" data-campaign-id="9d457e0e-3b40-456b-b6c7-01e3f5dec780" data-advertiser-id="c73dfcd7-7236-490d-b456-c6097406fdc3" data-landing-page="https://www.wayfair.com/decor-pillows/sb0/blinds-shades-c481847.html?refid=BRAVE&amp;bravecreativeid=clid=641.1&amp;pageexpansion=2" data-headline-text="Wayfair | Blinds &amp; Window Shades" data-description="At Your Doorstep Faster Than Ever. Fast &amp; Free Shipping On Orders Over $35. | Wayfair" data-rewards-value="0.3" data-optimized="false"> <div style="display: contents; --title-max-width: 86%;"><a href="/a/redirect?click_url=https%3A%2F%2Fwww.wayfair.com%2Fdecor-pillows%2Fsb0%2Fblinds-shades-c481847.html%3Frefid%3DBRAVE%26bravecreativeid%3Dclid%3D641.1%26pageexpansion%3D2&amp;placement_id=e4d9be7d-1aab-4a2f-912b-3db783cf7440&amp;creative_instance_id=3cce4974-9405-4345-9943-83478601f7f8&amp;nonce=470b3d0daab0516856425e39e9e28796&amp;sig=f4ad40084bd4da5a63aba0a061852898ae876f44f4095eb4e14d04718dd5c2a7" class="h svelte-1mekd5e" target="_self"><div class="url svelte-1mekd5e"><img alt="🌐" class="favicon svelte-6qi9un" src="https://imgs.search.brave.com/RGuoZem4hCcexAkLxiinvOynpLozKxgWYcfXS4UU36c/rs:fit:32:32:1/g:ce/aHR0cDovL2Zhdmlj/b25zLnNlYXJjaC5i/cmF2ZS5jb20vaWNv/bnMvNzY2YWE2Mjgy/ZmM1OWMyZWRlNjVm/NDk2ZTQ2NjgzNTJi/MmRiMzg5M2U5MmEw/NDI0YTI4M2NhMGE1/ZDNhYjcwNy93d3cu/d2F5ZmFpci5jb20v" loading="lazy"> <div class="title svelte-1mekd5e">Wayfair | Blinds &amp; Window Shades</div></div> <cite class="snippet-url svelte-163qink"> <span class="netloc svelte-163qink">wayfair.com</span> <span class="url-path svelte-163qink">› decor-pillows  › sb0  › blinds-shades-c481847.html</span> </cite></a></div> <div class="snippet-content svelte-uffi12"> <div class="snippet-description"> At Your Doorstep Faster Than Ever. Fast &amp; Free Shipping On Orders Over $35. | Wayfair</div></div> <button class="alabel svelte-1k4kzk9" data-svelte-h="svelte-eykjtv"><span class="label">Ad</span> <span class="bordered svelte-1k4kzk9">BETA</span></button>  <div style="position: relative"></div></div>
```


Discussion:
@return42 you can assign this to me if you want, I'll try fixing it later

Resolving patch:
diff --git a/searx/engines/brave.py b/searx/engines/brave.py
--- a/searx/engines/brave.py
+++ b/searx/engines/brave.py
@@ -246,7 +246,7 @@ def _parse_search(resp):
 
         url = eval_xpath_getindex(result, './/a[contains(@class, "h")]/@href', 0, default=None)
         title_tag = eval_xpath_getindex(result, './/div[contains(@class, "title")]', 0, default=None)
-        if url is None or title_tag is None:
+        if url is None or title_tag is None or not urlparse(url).netloc:  # partial url likely means it's an ad
             continue
 
         content_tag = eval_xpath_getindex(result, './/div[@class="snippet-description"]', 0, default='')


Test patch: