@@ -0,0 +1,34 @@
2+from urlparse import urljoin
4+from urllib import quote
6+categories = ['videos', 'music']
8+base_url = 'https://thepiratebay.sx/'
9+search_url = base_url + 'search/{search_term}/0/99/{search_type}'
10+search_types = {'videos': '200'
14+def request(query, params):
15+ global search_url, search_types
16+ # 200 is the video category
17+ params['url'] = search_url.format(search_term=quote(query), search_type=search_types.get(params['category']))
24+ dom = html.fromstring(resp.text)
25+ search_res = dom.xpath('//table[@id="searchResult"]//tr')
28+ for result in search_res[1:]:
29+ link = result.xpath('.//div[@class="detName"]//a')[0]
30+ url = urljoin(base_url, link.attrib.get('href'))
31+ title = ' '.join(link.xpath('.//text()'))
32+ content = escape(' '.join(result.xpath('.//font[@class="detDesc"]//text()')))
33+ results.append({'url': url, 'title': title, 'content': content})