View Single Post
Old Yesterday, 01:51 PM   #8
salamanderjuice
Guru
salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.salamanderjuice ought to be getting tired of karma fortunes by now.
 
Posts: 944
Karma: 13014268
Join Date: Jul 2017
Device: Boox Nova 2
Quote:
Originally Posted by Shohreh View Post
Thanks for the tips. There's a site where I can sell boxes of books for free that I used before. I just need to make a list.

Looks like isbnsearch.org is pretty good.

Before I look further, if someone here knows Python and Beautifulsoup, how do I get the author and published date?

Code:
"""
<div class="bookinfo">
	<h1>My Title</h1>
	<p><strong>ISBN-13:</strong> <a href="/isbn/123">123</a></p>
	<p><strong>ISBN-10:</strong> <a href="/isbn/456">456</a></p>
	<p><strong>Author:</strong> My Author</p>
	<p><strong>Binding:</strong> Paperback</p>
	<p><strong>Publisher:</strong> My Publisher</p>
	<p><strong>Published:</strong> 2009</p>
	<p>
		<a class="special-link" href="https://bookscouter.com/book/123" target="_blank">Sell this book</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a class="special-link" href="https://www.campusbooks.com/search/123?buysellrent=buy&popup" target="_blank">Buy or Rent?</a>
	</p>
</div>
"""

import requests
from bs4 import BeautifulSoup

HEADERS = ({'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36', 'Accept-Language': 'en-US, en;q=0.5'})

url = 'https://isbnsearch.org/isbn/123'

reqs = requests.get(url, headers=HEADERS)
soup = BeautifulSoup(reqs.text, 'lxml')
print("Title of the website is : ",soup.head.title.string)

div = soup.find("div", attrs={"class": 'bookinfo'})
print(div.h1.string)
for p in div("p"):
	#BAD print(p.string)
	print(p.text) #OK but I'd rather get the element's string
--
Edit: Not so good… After a while, isbn.org displays a "Please Verify to Continue". I'll go back to trying Amazon.

Code:
for div in soup("div", attrs={"class": 'puisg-col-inner'}):
	book_url = div.find("a", attrs={"class": 'a-link-normal s-line-clamp-2 s-link-style a-text-normal'})
	if book_url:
		print(book_url.string)
isbndb.com has an API, you get a request a second for free. Probably better for your use case.
salamanderjuice is offline   Reply With Quote