Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
scraper-central-ruby
Advanced tools
Ruby library to scrape and cache the data
Add gem scraper-central-ruby
into Gemfile:
gem 'scraper-central-ruby', git: 'git@github.com:patterninc/scraper-central-ruby.git', tag: 'v1.0.0'
bundle install
Add below configurations to service where this gem is being used.(ENV variables)
SERVER_URL_GET_CACHE=server base url for get cache
SERVER_URL_PUT_CACHE=server base url for put cache
Use ScraperCentral.new
to create new instance:
scraper_central = ScraperCentral.new
Customize the ScraperCentral instance using the provided options:
scraper_central = ScraperCentral.new
scraper_central.timeout = 45
scraper_central.tls_verify = false
scraper_central.enable_js = true
scraper_central.proxy_name = "ProxyName"
scraper_central.retry_attr = {
count: 5,
wait_time: 5,
max_wait_time: 5
}
To add custom headers and query parameters to your requests:
scraper_central = ScraperCentral.new
scraper_central.query_params = {
"query": "value",
"page_wait": "500"
}
scraper_central.headers = {
"X-Custom-Header": "value",
"mime-type": "text/html",
"Encoding": "gzip",
"ContentType": "application/json"
}
Customizing cookies:
scraper_central = ScraperCentral.new
scraper_central.cookies = `[
{
"Name":"amazon-cookie",
"Value":"Some session value",
"Path":"/",
"Domain":"amazon.com",
"MaxAge":36000,
"HttpOnly":true,
"Secure":false
},
{
"Name":"walmart-cookie",
"Value":"Some session value",
"Path":"/",
"Domain":"walmart.com",
"MaxAge":72000,
"HttpOnly":false,
"Secure":true
}
]`
To generate S3 key we require following methods to set-up:
scraper_central = ScraperCentral.new
scraper_central.s3_key = {
country: "US",
marketplace: "Amazon",
page_type: "detail-page",
identifier: "B0BQZBPS4G",
page_number: 1
}
scraper_central.cache_duration = 360
Fetches the URL through the proxy:
scraper_central = ScraperCentral.new
scraper_central.proxy_name = "BrightData"
scraper_central.cache_duration = 360
scraper_central.retry_attr = {
count: 5
}
scraper_central.s3_key = {
country: "US",
marketplace: "Amazon",
page_type: "product-question",
identifier: "B0BQZBPS4G",
page_number: 1
}
response = scraper_central.fetch("https://example.com")
...
puts "Response: ", response.body
puts "Status Code: ", response.code
puts "Headers: ", response.headers
scraper_central.proxy_name=
: Sets the proxy service name. e.g. CrawlBase
, BrightData
, ScraperApi
scraper_central.enable_js=
: Enables or disables JavaScript execution for proxies.scraper_central.retry_attr=
: Configures retry logic, including the number of attempts, wait time between attempts.scraper_central.timeout=
: Sets the request timeout in seconds.scraper_central.tls_verify=
: Configures TLS verification.scraper_central.query_params=
: Sets query parameters to be appended to each request URL.scraper_central.headers=
: Adds custom headers to requests. (Accept, Accept-Encoding or Content-Type).scraper_central.cookies=
: Parses a JSON string of cookies and sets them for subsequent requests.scraper_central.s3_key=
: Updates the proxy's target country or S3 key structure country, Marketplace, Pre defined names for page views, e.g. detail-page
. S3 key value for page identifer e.g. ASIN or Product ID. PageNumber if page is paginated.scraper_central.cache_duration=
: Age of object stored on S3 bucket.response = fetch(url)
: Makes a configured HTTP request to the specified URL and returns the response object.FAQs
Unknown package
We found that scraper-central-ruby demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.