Advertisement
Combreal

GetBookInfoGB.ps1

Mar 2nd, 2024
1,630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #9782368528310" #9782368528310 #9782382750216 #9782382751626 #9782871293545
  2.  
  3. $ISBN = "2382751622"
  4.  
  5. $req = Invoke-RestMethod -Method "GET" -URI "https://www.googleapis.com/books/v1/volumes?q=isbn:$ISBN"
  6. $infos = $req.items.volumeInfo
  7. $authors = $infos.authors
  8. $title = $infos.title
  9. $publishedDate = $infos.publishedDate
  10. $pageCount = $infos.pageCount
  11. $printType = $infos.printType
  12. $maturityRating = $infos.maturityRating
  13. $language = $infos.language
  14. $publisher = $infos.publisher
  15. $coverLink = ""
  16.  
  17. $parsedHtml = (Invoke-WebRequest $req.items.volumeInfo.infoLink).ParsedHtml
  18. $additionalInfos = ($parsedHtml.getElementsByTagName('td') | Where-Object { $_.className -eq 'metadata_value' }).innerText
  19. If ([String]::IsNullOrEmpty($req.items.volumeInfo.Authors)) {
  20.     $authors = $additionalInfos[1]
  21. }
  22.  
  23. If ([String]::IsNullOrEmpty($req.items.volumeInfo.publisher)) {
  24.     $publisher = $additionalInfos[2].Substring(0, $additionalInfos[2].IndexOf(","))
  25. }
  26.  
  27. If ([String]::IsNullOrEmpty($req.items.volumeInfo.pageCount) -Or $req.items.volumeInfo.pageCount -eq "0") {
  28.     $pageCount = $additionalInfos[4]
  29. }
  30.  
  31. write-host $authors
  32. write-host $title
  33. write-host $publishedDate
  34. write-host $pageCount
  35. write-host $printType
  36. write-host $maturityRating
  37. write-host $language
  38. write-host $publisher
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement