LXML based Nyaa parsing demo ready, DO NOT USE IT

This commit is contained in:
Ferenc Nánási
2020-01-13 23:11:55 +01:00
parent 495070e5ac
commit 03f030914b
4 changed files with 283 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import requests
import urllib.parse
from bs4 import BeautifulSoup
from NyaaPy import utils
from NyaaPy import utils_lxml
class Nyaa:
@@ -10,11 +10,16 @@ class Nyaa:
def last_uploads(self, number_of_results):
r = requests.get(self.URI)
soup = BeautifulSoup(r.text, 'html.parser')
rows = soup.select('table tr')
return utils.parse_nyaa(table_rows=rows, limit=number_of_results + 1)
# If anything up with nyaa servers let the user know.
r.raise_for_status()
return utils_lxml.parse_nyaa(
request_text=r.text,
limit=number_of_results + 1
)
"""
def search(self, keyword, **kwargs):
user = kwargs.get('user', None)
category = kwargs.get('category', 0)
@@ -52,3 +57,4 @@ class Nyaa:
soup = BeautifulSoup(r.text, 'html.parser')
return utils.parse_nyaa(soup.select('table tr'), limit=None)
"""