MrTyton / Fanfiction-Recommendation

3 stars 0 forks source link

Story Text #5

Closed depthfirst closed 8 years ago

depthfirst commented 8 years ago

Now supports getting the text of the story, extended from the Story class. Should probably put a different init function in, where you give it all of the information to begin with instead of scraping it from the page.

MrTyton commented 8 years ago

Did you merge in the change to Story.init?

On Wed, Nov 25, 2015 at 5:37 PM John Blackmore notifications@github.com wrote:

Merged #5 https://github.com/MrTyton/Fanfiction/pull/5.

— Reply to this email directly or view it on GitHub https://github.com/MrTyton/Fanfiction/pull/5#event-475036253.

depthfirst commented 8 years ago

Whatever you changed in master

depthfirst commented 8 years ago

So... how do I use this?

MrTyton commented 8 years ago

When you have the story object, call get_chapter_text(). This will populate a dictionary in the story object called chapter_texts, where the key is the chapter (starting from 1) and the value is the chapter itself. There's a lot of HTML formatting in there though... If a chapter couldn't be gotten (because of bad sockets or whatever) it just skips it, and the key isn't in the dictionary.

On Wed, Nov 25, 2015 at 5:52 PM John Blackmore notifications@github.com wrote:

So... how do I use this?

— Reply to this email directly or view it on GitHub https://github.com/MrTyton/Fanfiction/pull/5#issuecomment-159749573.

MrTyton commented 8 years ago

Er... I forgot to push the init change.

On Wed, Nov 25, 2015 at 6:02 PM Joshua Gang joshua.gang@gmail.com wrote:

When you have the story object, call get_chapter_text(). This will populate a dictionary in the story object called chapter_texts, where the key is the chapter (starting from 1) and the value is the chapter itself. There's a lot of HTML formatting in there though... If a chapter couldn't be gotten (because of bad sockets or whatever) it just skips it, and the key isn't in the dictionary.

On Wed, Nov 25, 2015 at 5:52 PM John Blackmore notifications@github.com wrote:

So... how do I use this?

— Reply to this email directly or view it on GitHub https://github.com/MrTyton/Fanfiction/pull/5#issuecomment-159749573.

MrTyton commented 8 years ago

Ok went and pulled the change for you... with a description

On Wed, Nov 25, 2015 at 6:04 PM Joshua Gang joshua.gang@gmail.com wrote:

Er... I forgot to push the init change.

On Wed, Nov 25, 2015 at 6:02 PM Joshua Gang joshua.gang@gmail.com wrote:

When you have the story object, call get_chapter_text(). This will populate a dictionary in the story object called chapter_texts, where the key is the chapter (starting from 1) and the value is the chapter itself. There's a lot of HTML formatting in there though... If a chapter couldn't be gotten (because of bad sockets or whatever) it just skips it, and the key isn't in the dictionary.

On Wed, Nov 25, 2015 at 5:52 PM John Blackmore notifications@github.com wrote:

So... how do I use this?

— Reply to this email directly or view it on GitHub https://github.com/MrTyton/Fanfiction/pull/5#issuecomment-159749573.

depthfirst commented 8 years ago

I don't have a story object. This seems complicated. All I really want is the full text, don't care about chapters.

MrTyton commented 8 years ago

The full text is going to just be all of the chapters together. The actual function that gets the chapter texts is first scrapePage.openStoryPage(url), followed by an indexer. Each of the chapters is a different URL so I had to do them one at a time.

Story object is because that's where it just seemed to make the most sense in the framework that I'd already made. If you want you can just change all of the arguments except for the storyID to be optional, or just try and call the function directly...

On Wed, Nov 25, 2015 at 6:11 PM John Blackmore notifications@github.com wrote:

I don't have a story object. This seems complicated. All I really want is the full text, don't care about chapters.

— Reply to this email directly or view it on GitHub https://github.com/MrTyton/Fanfiction/pull/5#issuecomment-159752345.