{"id":32785889,"url":"https://github.com/meanlifevn/book_toscrape_py","last_synced_at":"2026-04-20T06:07:08.743Z","repository":{"id":320993667,"uuid":"1084026372","full_name":"meanlifevn/book_toscrape_py","owner":"meanlifevn","description":"Fetching all the books raw on the books.toscrape.com. Create simple API.","archived":false,"fork":false,"pushed_at":"2025-10-27T06:01:15.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-05T04:04:19.950Z","etag":null,"topics":["api","booktoscrape","python","selenium"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meanlifevn.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-27T05:39:04.000Z","updated_at":"2025-10-27T06:03:11.000Z","dependencies_parsed_at":"2025-10-27T07:24:52.170Z","dependency_job_id":"e4bba9f4-dbf2-4740-b08b-8471a61555d9","html_url":"https://github.com/meanlifevn/book_toscrape_py","commit_stats":null,"previous_names":["meanlifevn/book_toscrape_py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/meanlifevn/book_toscrape_py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meanlifevn%2Fbook_toscrape_py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meanlifevn%2Fbook_toscrape_py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meanlifevn%2Fbook_toscrape_py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meanlifevn%2Fbook_toscrape_py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meanlifevn","download_url":"https://codeload.github.com/meanlifevn/book_toscrape_py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meanlifevn%2Fbook_toscrape_py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32035278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","booktoscrape","python","selenium"],"created_at":"2025-11-05T04:01:04.390Z","updated_at":"2026-04-20T06:07:08.737Z","avatar_url":"https://github.com/meanlifevn.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📚 Books Web Scraping \u0026 REST API Project\r\n\r\n## 🧩 Project Overview\r\n1. **Part 1:** Scrape book data from https://books.toscrape.com  \r\n2. **Part 2:** Use the REST Countries API to assign random publisher countries  \r\n3. **Part 3:** Build a FastAPI REST API to view, add, and delete books  \r\n\r\n---\r\n\r\n## ⚙️ Requirements\r\n```powershell\r\npip install -r requirements.txt\r\nbash setup.sh\r\n```\r\n\r\n---\r\n\r\n## 🚀 Run Instructions\r\n\r\n### 🕷️ 1. Scrape book data\r\n```powershell\r\npython p1_scrape_books.py\r\n```\r\nOutput:\r\n- `raw_books/` folder\r\n- `html_backup/` folder\r\n\r\n### 🌍 2. Add random countries\r\n```powershell\r\npython p2_add_country_data.py\r\n```\r\nOutput:\r\n- `raw_books/books_with_country.csv`\r\n- `raw_books/books_with_country.json`\r\n\r\n### 🧠 3. Start REST API\r\n```powershell\r\nuvicorn p3_books_api:app --reload\r\n```\r\nThen open your browser at:\r\n\r\n- Docs UI: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)\r\n- All books: [http://127.0.0.1:8000/books](http://127.0.0.1:8000/books)\r\n\r\n### 💾 Example Requests\r\n\r\n#### Filter by country: \r\n```powershell\r\ncurl.exe -X GET http://127.0.0.1:8000/books?country=Slovakia\r\n```\r\n#### How to add a new book:\r\nCreate a file `book_add.json`:\r\n```commandline  \r\n{\r\n        \"book_title\": \"Test Book\",\r\n        \"price\": \"£12.99\",\r\n        \"availability\": 16,\r\n        \"link\": \"https://example.com\",\r\n        \"rating\": 5,\r\n        \"publisher_country\": \"Japan\"\r\n}\r\n```\r\n```powershell\r\ncurl.exe -X POST \"http://127.0.0.1:8000/books\" `\r\n-H \"Content-Type: application/json\" `\r\n-d \"@book_add.json\"\r\n```\r\n#### Delete a book:\r\n```powershell\r\ncurl.exe -X DELETE 'http://127.0.0.1:8000/books/Test%20Book' `\r\n-H 'accept: application/json'\r\n```\r\n\r\n## 📂 Output Files\r\n- `raw_books/Self Help_3_books.csv`\r\n- `raw_books/books_with_country.csv`\r\n- `raw_books/books_with_country.json`\r\n- `html_backup/` (raw HTML for each book)\r\n\r\n## ⚠️ Notes\r\n- Make sure to run **Part 1** before **Part 2**, and **Part 3** before starting the API.  \r\n- All commands are tested and run in **PowerShell inside PyCharm** for correct execution on Windows.  \r\n- Use PowerShell when executing the `curl.exe` commands to handle special characters properly.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeanlifevn%2Fbook_toscrape_py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeanlifevn%2Fbook_toscrape_py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeanlifevn%2Fbook_toscrape_py/lists"}