Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The API(s) provided by query-server are as follows:

` GET /api/v1/search/<search-engine>?query=query&format=format `

> *search-engine* : [`google`, `ask`, `bing`, `duckduckgo`, `yahoo`, `yandex`, `baidu`, `exalead`, `quora`, `youtube`, `parsijoo`]
> *search-engine* : [`google`, `ask`, `bing`, `duckduckgo`, `yahoo`, `yandex`, `baidu`, `exalead`, `quora`, `youtube`, `parsijoo`, `mojeek`]

> *query* : query can be any string

Expand Down
4 changes: 3 additions & 1 deletion app/scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from quora import Quora
from youtube import Youtube
from parsijoo import Parsijoo
from mojeek import Mojeek

scrapers = {
'g': Google(),
Expand All @@ -24,7 +25,8 @@
'e': Exalead(),
'q': Quora(),
't': Youtube(),
'p': Parsijoo()
'p': Parsijoo(),
'm': Mojeek()
}


Expand Down
26 changes: 26 additions & 0 deletions app/scrapers/mojeek.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import print_function
from generalized import Scraper


class Mojeek(Scraper):
"""Scraper class for Mojeek"""

def __init__(self):
self.url = 'https://www.mojeek.co.uk/search'
self.defaultStart = 1
self.startKey = 's'

def parseResponse(self, soup):
""" Parse the response and return set of urls
Returns: urls (list)
[[Tile1,url1], [Title2, url2],..]
"""
urls = []
for a in soup.findAll('a', {'class': 'ob'}):
title = a.getText()
url = a.get('href')
urls.append({'title': title, 'link': url})

print('Mojeek parsed: ' + str(urls))

return urls
2 changes: 1 addition & 1 deletion app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def search(search_engine):
engine = search_engine
if engine not in ('google', 'bing', 'duckduckgo', 'yahoo', 'ask',
'yandex', 'ubaidu', 'exalead', 'quora', 'tyoutube',
'parsijoo'):
'parsijoo', 'mojeek'):
err = [404, 'Incorrect search engine', qformat]
return bad_request(err)

Expand Down
Binary file added app/static/images/mojeek_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ <h1><code>query-server</code></h1>
<button type="submit" value="exalead" class="btn btn-lg search btn-outline"><img src="{{ url_for('static', filename='images/exalead_icon.png') }}" width="30px" alt="Exalead Icon"> Exalead</button>
<button type="submit" value="quora" class="btn btn-lg search btn-outline"><img src="{{ url_for('static', filename='images/quora_icon.png') }}" width="30px" alt="Quora Icon"> Quora</button>
<button type="submit" value="parsijoo" class="btn btn-lg search btn-outline"><img src="{{ url_for('static', filename='images/parsijoo_icon.png') }}" width="30px" alt="Parsijoo Icon"> Parsijoo</button>
<button type="submit" value="mojeek" class="btn btn-lg search btn-outline"><img src="{{ url_for('static', filename='images/mojeek_icon.png') }}" width="30px" alt="Mojeek Icon"> Mojeek</button>
<button type="submit" value="tyoutube" class="btn btn-lg search btn-outline"><img src="{{ url_for('static', filename='images/youtube_icon.png') }}" width="30px" alt="YouTube Icon"> YouTube</button>
</div>
</div>
Expand Down