def get_book_data_from_site(self, url): """ args: url (String): Kobo book url to be parsed returns: SiteBookData (List): format (String): book_title (String): book_image:~ book_image_url (String): isbn_13 (String): description (String): series (String):~ volume_number (Int):~ subtitle (String):~ authors (String): book_id: site_slug (String): parse_status (String):~ url (String): content (String): ready_for_sale (boolean):~ extra:~ synopsis: The purpose of this function is to parse a url of the Kobo website. The url should be a specific book's url, in order for the following function to work. This function works with both digital books and audio books. """ response = requests.get(url) extra = {} # book_title book_title = self._get_book_title(response.content) # book_image_url book_image_url = self._get_book_image_url(response.content) # book_image book_image = Par_Scrape.get_book_image_from_image_url(book_image_url) # isbn_13 isbn_13 = self._get_book_isbn_13(response.content) # description description = self._get_book_description(response.content) # series series = self._get_book_series(response.content) # volume_number volume_number = self._get_book_volume_number(response.content) # subtitle subtitle = self._get_book_subtitle(response.content) # authors authors = self._get_book_authors(response.content) # url url = self._get_book_url(response.content) # site_slug site_slug = self._get_book_site_slug() # book_id book_id = self._get_book_id(response.content) # format book_format = self._get_book_format(response.content) # content content = response.content # ready_for_sale ready_for_sale = self._get_book_availability(response.content) # parse_status parse_status = Par_Scrape.parse_status([ book_format, book_title, book_image, book_image_url, isbn_13, description, authors, book_id, site_slug, url, content, ready_for_sale ]) SiteBookData = [ book_format, book_title, book_image, book_image_url, isbn_13, description, series, volume_number, subtitle, authors, book_id, site_slug, parse_status, url, content, ready_for_sale, extra ] return SiteBookData
None, #05-description (String) None, #06-series (String) None, #07-volume_number (Int) None, #08-subtitle (String) None, #09-authors (String) None, #10-book_id (String) None, #11-site_slug (String) None, #12-parse_status (String) None, #13-url (String) None, #14-content (String) None, #15-ready_for_sale (boolean) None] #16-extra (List[]) ''' book_image_url = "https://imgv2-2-f.scribdassets.com/img/word_document/356970421/original/e058724125/1582611379?v=1" tempImage = Par_Scrape.get_book_image_from_image_url(book_image_url) #BOOK DATA book_data = [None, #00-format (String) "The name of the wind", #01-book_title (String) None, #02-book_image (PIL.Image) None, #03-book_image_url (String) "9781423389309", #04-isbn_13 (String) "My name is Kvothe. I have stolen princesses back from sleeping barrow kings. I burned down the town of Trebon. I have spent the night with Felurian and left with both my sanity and my life. I was expelled from the University at a younger age than most people are allowed in. I tread paths by moonlight that others fear to speak of during day. I have talked to Gods, loved women, and written songs that make the minstrels weep. You may have heard of me. So begins a tale unequaled in fantasy literature-the story of a hero told in his own voice. It is a tale of sorrow, a tale of survival, a tale of one man's search for meaning in his universe, and how that search, and the indomitable will that drove it, gave birth to a legend. \"It is a rare and great pleasure to find a fantasist writing…with true music in the words…. Wherever Pat Rothfuss goes…he'll carry us with him as a good singer carries us through a song.\" -Ursula K. Le Guin, bestselling author and winner of the National Book Award", #05-description (String) None, #06-series (String) None, #07-volume_number (Int) None, #08-subtitle (String) "Patrick Rothfuss", #09-authors (String) None, #10-book_id (String) "au", #11-site_slug (String)
def get_book_data_from_site(self, url): """ args: url (String): Google Books book url to be parsed returns: SiteBookData (List): format (String): book_title (String): book_image:~ book_image_url (String): isbn_13 (String): description (String): series (String):~ volume_number (String):~ subtitle (String):~ authors (String): book_id (String): site_slug (String): parse_status (String):~ url (String): content (String): ready_for_sale (boolean):~ extra:~ synopsis: The purpose of this function is to parse a url of the Audiobooks website. The url should be a specific book's url, in order for the following function to work. """ response = requests.get(url) format = None book_title = None book_image = None book_image_url = None isbn_13 = None description = None series = None volume_number = None subtitle = None authors = None book_id = None site_slug = None parse_status = None book_url = None content = None ready_for_sale = None extra = None # book_title book_title = self._get_book_title(response.content) # book_image_url book_image_url = self._get_book_image_url(response.content) # book_image book_image = Par_Scrape.get_book_image_from_image_url(book_image_url) # book_isbn_13 isbn_13 = self._get_book_isbn_13() # description description = self._get_book_description(response.content) # series series = self._get_book_series() # volume_number volume_number = self._get_book_volume() # subtitle subtitle = self._get_book_subtitle() # authors authors = self._get_book_authors(response.content) # book_url book_url = url # site_slug site_slug = self._get_book_site_slug() # book_id book_id = self._get_book_id(response.url) # format format = self._get_book_format() # content content = response.content # ready_for_sale ready_for_sale = self._get_book_sale_status(response.content) # parse_status parse_status = Par_Scrape.parse_status([format, book_title, book_image, book_image_url, description, authors, book_id, site_slug, url, content, ready_for_sale]) SiteBookData = [format, book_title, book_image, book_image_url, isbn_13, description, series, volume_number, subtitle, authors, book_id, site_slug, parse_status, url, content, ready_for_sale, extra] return SiteBookData
def get_book_data_from_site(self, url): content = self.__fetch__(url) format = None book_title = None book_image = None book_image_url = None isbn_13 = None description = None series = None volume_number = None subtitle = None authors = None book_id = None site_slug = None parse_status = None url = None ready_for_sale = None extra = None #format format = 'DIGITAL' #book_title book_title = self.__get_title__(content) #subtitle subtitle = self.__get_subtitle__(content) #book_image_url book_image_url = self.__get_book_image_url__(content) #book_image book_image = Par_Scrape.get_book_image_from_image_url(book_image_url) #isbn_13 isbn_13 = self.__get_isbn__(content) #description description = self.__get_description__(content) #authors authors = self.__get_authors__(content) #book_id book_id = self.__get_book_id__(content) #site_slug site_slug = 'LC' #url url = self.__get_url__(content) #ready_for_sale ready_for_sale = True #price = None if subtitle == None: parse_list = [format, book_title, book_image, book_image_url, isbn_13, description, authors, book_id, site_slug, url, content, ready_for_sale] else: parse_list = [format, book_title, book_image, book_image_url, isbn_13, description, subtitle, authors, book_id, site_slug, url, content, ready_for_sale] #parse_status parse_status = Par_Scrape.parse_status(parse_list) SiteBookData = [format, book_title, book_image, book_image_url, isbn_13, description, series, volume_number, subtitle, authors, book_id, site_slug, parse_status, url, content, ready_for_sale, extra] return SiteBookData