yoonwaiyan / stackskills-dl

Simple Ruby script to download all StackSkills tutorials.
https://yoonwaiyan.github.io/stackskills-dl/
MIT License
59 stars 19 forks source link

"Unable to find this course: [...] from your list of courses." #25

Closed boettges closed 7 years ago

boettges commented 7 years ago

Hello, I've got the suspicion that the whole script is ignoring the pagination of the "my courses" page. One page only displays 36 courses. I can't download courses that are on page 2.

Any solution for this? How can I help resolving the issue? Thanks a lot in advance.

yoonwaiyan commented 7 years ago

It's not "ignoring", but I've yet managed to view the "page 2" of the course list page. Are you on stackskills.com or some other domain? Please refer to #17.

boettges commented 7 years ago

Sadly this didn't help. I'm on regular stackskills.com and currently have 3 pages shown. Due to bigger bundles I've accummulated 92 courses in total over the year.

The pagination counts reflects in the url like this: https://stackskills.com/courses/enrolled https://stackskills.com/courses/enrolled?page=2 https://stackskills.com/courses/enrolled?page=3

In "pseudo code" something like this has to be realized:

  1. check if pagination exists
  2. scan page n=1 with "base url"
  3. loop through pages from nā‰„2 with alteration of the url, as seen above
  4. scan each page and append data to the course list array
  5. if page n+1 leads to http-error, exit loop

This would be necessary as I don't know how the pagination works with higher page numbers, at some point ā€“ I assume ā€“ it will ellipse pages. It's either: 1,2,3,... (bad) or 1,2,...,8 (good). For that latter the last page's count is directly shown, so there's no need to check for an http-error.

Maybe you can ramp up your number of courses to get past the 36-threshold by using the free courses offered here: https://www.skillwise.com/free ā€” Redeeming the codes adds those courses to your stackskills profile.

I'm also very willing to help, just not sure about realizing this in ruby...

Thanks a lot and cheers šŸ‘

yoonwaiyan commented 7 years ago

@boettges Thanks! The number of free courses wasn't enough to fill up my list back then but seems like they've added couples of courses now. Will work on it later (Y) .

boettges commented 7 years ago

@yoonwaiyan I found a work around by manually changing the indexed page to "...?page=2".

In https://github.com/yoonwaiyan/stackskills-dl/blob/master/lib/course_finder.rb I changed line 30 from self.current_page = user_dashboard

to self.current_page = agent.get("https://stackskills.com/?page=2")

It's a not very elegant work around, as you manually have to alter the URL, but so far it works.

yoonwaiyan commented 7 years ago

Hi there, yes the workaround is working but it's limited to one page.

I have updated the code to navigate through pages to get all courses. Please re-open the issue if the fix is not working. Thanks.

boettges commented 7 years ago

Thanks a lot! Will give it a go later on.

The only issue that I foresee is that fetching the course list now might take longer on each download.