25 lines
736 B
Python
25 lines
736 B
Python
|
import json
|
||
|
import os
|
||
|
import shutil
|
||
|
import requests
|
||
|
|
||
|
BASE_URL = 'https://oldschool.runescape.wiki/api.php?action=query&list=search&srwhat=text&format=json&srsearch='
|
||
|
|
||
|
class OSRSSearch(object):
|
||
|
def __init__(self):
|
||
|
self._session = requests.Session()
|
||
|
|
||
|
def request(self, method, url, params=None, verify_ssl=True, timeout=60):
|
||
|
response = self._session.request(method, url, params=params, verify=verify_ssl, timeout=timeout)
|
||
|
response.raise_for_status()
|
||
|
return response
|
||
|
|
||
|
def search(self, query):
|
||
|
if not query:
|
||
|
query = ''
|
||
|
params = {
|
||
|
('srsearch', query)
|
||
|
}
|
||
|
response = self.request("get", BASE_URL, params)
|
||
|
return response.json()
|
||
|
|