Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This is a Scrapy middlware that provides an interface for interacting with the ZenRows® Scraper API in your Scrapy spiders. It lets you enjoy all the features of the ZenRows® Scraper API while using scrapy.
The ZenRows® Scraper API is an all-in-one toolkit designed to simplify and enhance the process of extracting data from websites. Whether you’re dealing with static or dynamic content, our API provides a range of features to meet your scraping needs efficiently.
With Premium Proxies, ZenRows gives you access to over 55 million residential IPs from 190+ countries, ensuring 99.9% uptime and highly reliable scraping sessions. Our system also handles advanced fingerprinting, header rotation, and IP management, enabling you to scrape even the most protected sites without needing to manually configure these elements.
ZenRows makes it easy to bypass complex anti-bot measures, handle JavaScript-heavy sites, and interact with web elements dynamically — all with the right features enabled.
pip install scrapy-zenrows
DOWNLOADER_MIDDLEWARE
and specify your ZenRows API Key:settings.py
DOWNLOADER_MIDDLEWARES = {
"scrapy_zenrows.ZenRowsMiddleware": 543,
}
# ZenRows API Key
ZENROWS_API_KEY = "<YOUR_ZENROWS_API_KEY>"
The middleware will not use premium proxy and JS rendering by default. So, USE_ZENROWS_PREMIUM_PROXY
and USE_ZENROWS_JS_RENDER
are False
by default. To turn on premium proxy and JS rendering globally, set both parameters to True
:
settings.py
# ...
USE_ZENROWS_PREMIUM_PROXY = True # to turn on premium proxy (False by default)
USE_ZENROWS_JS_RENDER = True # to turn on JS rendering (False by default)
If you have multiple spiders and don't want to apply global premium proxy and JS rendering for all, you can apply the middleware to specific ones by using ZenRowsRequest
in start_requests
.
ZenRowsRequest
accepts the URL, request params, and headers options.
For example, to set Premium Proxy and JS Rendering for a specific request:
# pip install scrapy-zenrows
from scrapy_zenrows import ZenRowsRequest
class YourSpider(scrapy.Spider):
# ...
def start_requests(self):
# use ZenRowsRequest for customization
for url in self.start_urls:
yield ZenRowsRequest(
url=url,
# overrides the settings config for this specific spider
params={
"js_render": "true", # enable JavaScript rendering (if needed)
"premium_proxy": "true", # use the proxy (if needed)
},
)
def parse(self, response):
# ...
In addition to js_render
and premium_proxy
, the ZenRowsRequest
accepts other parameters accepted by the ZenRows Scraper API:
# ...
class YourSpider(scrapy.Spider):
# ...
def start_requests(self):
# use ZenRowsRequest for customization
for url in self.start_urls:
yield ZenRowsRequest(
url=url,
params={
# ...,
"proxy_country": "ca", # use proxy from a specific country
"js_instructions": '[{"wait": 500}]', # pass JS instructions
"autparse": "true", # for supported websites
"outputs": "tables" # extract specific data,
'css_extractor': '{"links":"a @href","images":"img @src"}'
""
},
)
For more information and supported parameters, check out our Scraper API features.
You must set the custom_headers
parameter to true in your request to use customized headers. This tells ZenRows to include your custom headers while managing critical browser-based headers.
For example, the following adds the referer header:
# ...
class YourSpider(scrapy.Spider):
# ...
def start_requests(self):
# use ZenRowsRequest for customization
for url in self.start_urls:
yield ZenRowsRequest(
url=url,
# overrides the settings config for this specific spider
params={
"custom_headers": "true", # to use custom headers
},
# add a referer header
headers={
"Referer": "https://www.google.com/",
},
)
Pass Cookies as a meta parameter (separated from the headers
) just as specified by Scrapy. However, custome_headers
must also be set to true.
# ...
class YourSpider(scrapy.Spider):
# ...
def start_requests(self):
# use ZenRowsRequest for customization
for url in self.start_urls:
yield ZenRowsRequest(
url=url,
# overrides the settings config for this specific spider
params={
"custom_headers": "true", # to use custom headers
},
cookies={
"currency": "USD",
"country": "UY",
},
)
Check our headers feature for more information on the accepted request headers and how to set them.
Here are example spider demonstrating how to use the scrapy_zenrows
middleware:
ZenRowsRequest
.ZenRowsRequest
.ZenRowsRequest
.outputs
feature of the ZenRows Scraper API. Check the supported outputs for more information.Examples directory: examples
FAQs
A Scrapy middleware for accessing ZenRows Scraper API with minimal setup.
We found that scrapy-zenrows demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.