← ClaudeAtlas

scraperapi-ruby-sdklisted

Best-practices reference for the ScraperAPI Ruby SDK (scraperapi gem). Consult whenever the user is writing, debugging, or reviewing Ruby code that calls ScraperAPI. Use when user asks: "scrape a website with Ruby and ScraperAPI", "ScraperAPI Ruby example", "how do I use the ScraperAPI gem", "Ruby ScraperAPI render", "ScraperAPI Ruby premium proxy", "ScraperAPI gem sessions", "ScraperAPI Ruby error handling". Covers gem setup, all request parameters, the escalation ladder, error handling by status code, and credit costs.
scraperapi/scraperapi-skills · ★ 9 · AI & Automation · score 78
Install: claude install-skill scraperapi/scraperapi-skills
# ScraperAPI — Ruby SDK Best Practices **Requires:** Ruby >= 2.0, `gem install scraperapi` (or `gem 'scraperapi'` in Gemfile), `SCRAPERAPI_API_KEY` environment variable. ## Setup ```ruby require "scraper_api" client = ScraperAPI::Client.new(ENV["SCRAPERAPI_API_KEY"]) ``` Never hardcode the API key. Read it from the environment every time. ## Basic Usage ```ruby # Simple GET — returns raw HTML string via .raw_body html = client.get("https://example.com/").raw_body puts html # With a single parameter html = client.get("https://example.com/", render: true).raw_body # With multiple parameters html = client.get( "https://example.com/", render: true, country_code: "us" ).raw_body ``` Parameters are passed as keyword arguments after the URL. `.raw_body` extracts the HTML string from the response object. ## Decision Guide | Situation | Approach | |-----------|---------| | Single URL, synchronous | `client.get(url, **params).raw_body` | | Page loads content via JavaScript | Pass `render: true` | | Site blocks datacenter proxies | Pass `premium: true` | | Toughest anti-bot protection | Pass `ultra_premium: true` | | Multi-step / paginated flow on same domain | Use `session_number:` | | 20+ URLs or batch jobs | Use async endpoint via `Net::HTTP` or `Faraday` | | Supported platform (Amazon, Google, etc.) | Use structured data endpoint directly | ## Parameter Reference ### Rendering ```ruby # Render JavaScript before returning HTML # Use when: page is a React/Vue/Angu