Skip to content

Navigation Menu

Sign in
Sign up

Retrieve a specific n page #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
iwkse wants to merge 2 commits into MTG:master
base: master
Choose a base branch
Loading
from iwkse:master
Open
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
22 changes: 21 additions & 1 deletion freesound.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try: # python 3
from urllib.request import urlopen, FancyUrlOpener, Request # noqa
from urllib.parse import urlencode, quote
from urllib.parse import urlparse, urlencode, quote
from urllib.error import HTTPError
except ImportError: # python 2.7
from urllib import urlencode, FancyURLopener, quote
Expand Down Expand Up @@ -281,6 +281,26 @@ def previous_page(self):
Get a Pager with the previous results page.
"""
return FSRequest.request(self.previous, {}, self.client, Pager)
def get_page(self, n):
url = self.next

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if self.next is None (which could happen if there are no other pages)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 2016年8月29日 08:07:56 -0700
Frederic Font notifications@github.com wrote:

@@ -281,6 +281,23 @@ def previous_page(self):
Get a Pager with the previous results page.
"""
return FSRequest.request(self.previous, {}, self.client, Pager)

  • def get_page(self, n):
  •  url = self.next
    

This will fail if self.next is None (which could happen if there are no other
pages)

True, but it's not going to fail because I do check the boundaries and this is
not called

Salvatore


if (url):
uri = urlparse(url)
for index,item in enumerate(uri):
if ('query' in item):
urid=index

query = uri[urid].split("&")

for index,item in enumerate(query):
if ("page" in item):
query[index] = 'page=' + str(n)

url = uri[0] + '://' + uri[1] + uri[2] + '?' + "&".join(query)
return FSRequest.request(url, {}, self.client, Pager)
else:
return None



class GenericPager(Pager):
Expand Down

AltStyle によって変換されたページ (->オリジナル) /