Skip to content
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

Support fetching all comments now that comments=all does not work #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions aur-comment-fetch
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def query(name):
raise click.ClickException('couldn\'t find any package with name "{0}"'
.format(name))

def get(package):
res = requests.get(BASE_URL+package+'/?comments=all',verify=True)
def get(package, count=100000):
res = requests.get(BASE_URL+package+'/?comments=all&PP='+str(count),verify=True)
if res.status_code != 200:
res = requests.get(BASE_URL+query(package)+'/?comments=all',verify=True)
res = requests.get(BASE_URL+query(package)+'/?comments=all&PP='+str(count),verify=True)
if res.status_code != 200:
raise click.ClickException('couldn\'t fetch comments for package "{0}"'
.format(package))
return res

def fetch_comments(package,number=5,get_all=False):
res = get(package)
res = get(package, 100000 if get_all else number)
soup = BeautifulSoup(res.content, 'lxml')
# find only next element
current = soup.find('div',attrs={'class':'comments'})
Expand Down