Fix #14
This commit is contained in:
@@ -6,7 +6,13 @@ class Nyaa():
|
|||||||
'''
|
'''
|
||||||
Return a list of dicts with the results of the query.
|
Return a list of dicts with the results of the query.
|
||||||
'''
|
'''
|
||||||
def search(keyword, category, subcategory, filters, page):
|
def search(keyword, **kwargs):
|
||||||
|
|
||||||
|
category = kwargs.get('category', 0)
|
||||||
|
subcategory = kwargs.get('subcategory', 0)
|
||||||
|
filters = kwargs.get('filters', 0)
|
||||||
|
page = kwargs.get('page', 0)
|
||||||
|
|
||||||
if page > 0:
|
if page > 0:
|
||||||
r = requests.get("http://nyaa.si/?f={}&c={}_{}&q={}&p={}".format(filters, category, subcategory, keyword, page))
|
r = requests.get("http://nyaa.si/?f={}&c={}_{}&q={}&p={}".format(filters, category, subcategory, keyword, page))
|
||||||
else:
|
else:
|
||||||
@@ -30,4 +36,4 @@ class Nyaa():
|
|||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
rows = soup.select('table tr')
|
rows = soup.select('table tr')
|
||||||
|
|
||||||
return utils.parse_nyaa(rows, limit=number_of_results)
|
return utils.parse_nyaa(rows, limit=number_of_results + 1)
|
||||||
10
README.md
10
README.md
@@ -51,11 +51,11 @@ Returns a list of dicts with the search results.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
* **keyword**: String. Keyword for the search query.
|
* **keyword**: String. Keyword for the search query. Mandatory.
|
||||||
* **category**: Integer.
|
* **category**: Integer. Optional.
|
||||||
* **subcategory**: Integer.
|
* **subcategory**: Integer. Optional.
|
||||||
* **filters**: Integer.
|
* **filters**: Integer. Optional.
|
||||||
* **page**: Integer.
|
* **page**: Integer. Optional.
|
||||||
|
|
||||||
`page` must be between 0 and 1000.
|
`page` must be between 0 and 1000.
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -1,7 +1,7 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(name='nyaapy',
|
setup(name='nyaapy',
|
||||||
version='0.4.1',
|
version='0.4.3',
|
||||||
url='https://github.com/juanjosalvador/nyaapy',
|
url='https://github.com/juanjosalvador/nyaapy',
|
||||||
download_url = 'https://github.com/juanjosalvador/nyaapy/archive/0.1.tar.gz',
|
download_url = 'https://github.com/juanjosalvador/nyaapy/archive/0.1.tar.gz',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
|
|||||||
@@ -1,31 +1,12 @@
|
|||||||
from NyaaPy import Nyaa, NyaaPantsu
|
from NyaaPy import Nyaa
|
||||||
|
|
||||||
# Nyaa.si results
|
# Nyaa.si results
|
||||||
def nyaa_search():
|
nyaa_query = Nyaa.search()
|
||||||
try:
|
|
||||||
nyaa_query = Nyaa.search(keyword='koe no katachi 1080', category=1, subcategory=0, page=0)
|
|
||||||
|
|
||||||
for nyaa in nyaa_query:
|
nyaa_news = Nyaa.news(5)
|
||||||
print(nyaa)
|
|
||||||
except TypeError as te:
|
|
||||||
print(te)
|
|
||||||
|
|
||||||
def nyaa_news():
|
if len(nyaa_query) > 0:
|
||||||
news = Nyaa.news(number_of_results=5)
|
for result in nyaa_query:
|
||||||
for n in news:
|
print(result['name'])
|
||||||
print(n)
|
else:
|
||||||
|
print('Nothing here!')
|
||||||
# Nyaa.pantsu.cat results
|
|
||||||
def pantsu_search():
|
|
||||||
pantsu_query = NyaaPantsu.search('new game!!')
|
|
||||||
|
|
||||||
|
|
||||||
def pantsu_news():
|
|
||||||
print(NyaaPantsu.news(1))
|
|
||||||
|
|
||||||
# Uncomment whatever you want to test
|
|
||||||
|
|
||||||
#nyaa_search()
|
|
||||||
#pantsu_search()
|
|
||||||
#nyaa_news()
|
|
||||||
pantsu_news()
|
|
||||||
Reference in New Issue
Block a user