Skip to content

/scrape examples

By default, ScrapeNinja interprets data property as raw data for POST request. It’s perfect for sending JSON blobs to target website. To make it interpret the data as www-form-urlencoded data, pass "Content-Type: application/x-www-form-urlencoded" into headers array:

Terminal window
curl --request POST \
--url https://scrapeninja.p.rapidapi.com/scrape \
--header 'X-RapidAPI-Host: scrapeninja.p.rapidapi.com' \
--header 'X-RapidAPI-Key: YOUR KEY' \
--header 'content-type: application/json' \
--data '{
"url": "https://website.com/post.php",
"headers": [
"Content-Type: application/x-www-form-urlencoded"
],
"method": "POST",
"data": "key1=val1&key2=val2"
}'

upload property value of multipart is the name of the input to attach the multipart data to.

Terminal window
curl --request POST \
--url https://scrapeninja.p.rapidapi.com/scrape \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"multipart": "upload",
"url": "https://scrapeninja.net/samples/post-json",
"method": "POST",
"data": "key1=val1&key2=val2&ewfew=23f23f23f32&wgewllfwejfewijewj33mme=ewfewfjwjeje33233232&key2"
}'

Use textNotExpected which accepts an array of strings. ScrapeNinja already has some certain Cloudflare string occurences hardcoded, but you can add your own. If the string is found in the response, ScrapeNinja will retry the request up to retryNum attempts (default retryNum value is 2).

Terminal window
curl --request POST \
--url https://scrapeninja.p.rapidapi.com/scrape \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"url": "https://website.com/post.php",
"textNotExpected": ["<div id=\"p\">Your request was blocked</div>", "Some other unique text to retry"],
"retryNum": 3
}'