#19 fixed, need to be tested
This commit is contained in:
@@ -21,13 +21,16 @@ class Nyaa:
|
|||||||
soup = BeautifulSoup(r.text, 'html.parser')
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
rows = soup.select('table tr')
|
rows = soup.select('table tr')
|
||||||
|
|
||||||
results = {}
|
return utils.parse_nyaa(rows, limit=None)
|
||||||
|
|
||||||
if rows:
|
|
||||||
results = utils.parse_nyaa(rows, limit=None)
|
|
||||||
|
|
||||||
return results
|
def get(url):
|
||||||
|
r = requests.get("https://nyaa.si/view/975533")
|
||||||
|
soup = BeautifulSoup(r.text, 'html.parser')
|
||||||
|
content = soup.findAll("div", { "class": "panel panel-default", "id": None})
|
||||||
|
|
||||||
|
return utils.parse_single(content)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Returns an array of dicts with the n last updates of Nyaa.si
|
Returns an array of dicts with the n last updates of Nyaa.si
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Module utils
|
Module utils
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class Utils():
|
class Utils:
|
||||||
|
|
||||||
def nyaa_categories(b):
|
def nyaa_categories(b):
|
||||||
c = b.replace('/?c=', '')
|
c = b.replace('/?c=', '')
|
||||||
@@ -106,6 +106,37 @@ class Utils():
|
|||||||
|
|
||||||
return torrents
|
return torrents
|
||||||
|
|
||||||
|
def parse_single(content):
|
||||||
|
torrent = {}
|
||||||
|
data = []
|
||||||
|
torrent_files = []
|
||||||
|
|
||||||
|
for row in content[0].find_all('div', {'class': 'row'}):
|
||||||
|
for div in row.find_all('div', {'class': 'col-md-5'}):
|
||||||
|
data.append(div.text.replace("\n", ""))
|
||||||
|
|
||||||
|
files = content[2].find('div', {'class', 'torrent-file-list'}).find_all('li')
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
torrent_files.append(file.text)
|
||||||
|
|
||||||
|
|
||||||
|
torrent['title'] = content[0].find('h3', {"class": "panel-title"}).text.replace("\n", "")
|
||||||
|
torrent['category'] = data[0]
|
||||||
|
torrent['uploader'] = data[2]
|
||||||
|
torrent['uploader_profile'] = "https://nyaa.si/user/{}".format(data[2])
|
||||||
|
torrent['website'] = data[4]
|
||||||
|
torrent['size'] = data[6]
|
||||||
|
torrent['date'] = data[1]
|
||||||
|
torrent['seeders'] = data[3]
|
||||||
|
torrent['leechers'] = data[5]
|
||||||
|
torrent['completed'] = data[7]
|
||||||
|
torrent['hash'] = data[8]
|
||||||
|
torrent['description'] = content[1].find('div', {'id': 'torrent-description'}).text
|
||||||
|
torrent['files'] = torrent_files
|
||||||
|
|
||||||
|
return torrent
|
||||||
|
|
||||||
def query_builder(q, params):
|
def query_builder(q, params):
|
||||||
available_params = ["category", "page", "limit", "userID", "fromID", "status", "maxage", "toDate", "fromDate",\
|
available_params = ["category", "page", "limit", "userID", "fromID", "status", "maxage", "toDate", "fromDate",\
|
||||||
"dateType", "minSize", "maxSize", "sizeType", "sort", "order", "lang"]
|
"dateType", "minSize", "maxSize", "sizeType", "sort", "order", "lang"]
|
||||||
|
|||||||
Reference in New Issue
Block a user