pionxzh / Pornhub.js

Powerful PornHub API for Node.js
MIT License
90 stars 19 forks source link

Invalid json response body #124

Closed masterindex1 closed 2 weeks ago

masterindex1 commented 3 weeks ago

Everything works when running locally. But after I deploy I get this error.

FetchError: invalid json response body at https://www.pornhub.com/webmasters/search?search=hd%2B&page=1&period=alltime&ordering=newest&thumbsize=large_hd&tags%5B%5D=Cowgirl%2CDoggystyle&category= reason: Unexpected token '<', "

<!DOCTYPE "... is not valid JSON at /var/task/node_modules/node-fetch/lib/index.js:273:32 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async search (file:///var/task/node_modules/pornhub.js/dist/index.mjs:971:20) at async searchVideos (file:///var/task/routes/search.js:88:39) { type: 'invalid-json' }

masterindex1 commented 3 weeks ago

"<!DOCTYPE "... is not valid JSON at /var/task/node_modules/node-fetch/lib/index.js:273:32 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async search (file:///var/task/node_modules/pornhub.js/dist/index.mjs:971:20) at async searchVideos (file:///var/task/routes/search.js:88:39) { type: 'invalid-json' }"

pionxzh commented 2 weeks ago

You might be blocked because of sending a request from known cloud IP lists. Some anti-robot things.

Invalid JSON and the Unexpected token '<', basically indicated that you get a 404 or 500 error.

Try starting your app with

const pornhub = new PornHub({ dumpPage: true });

A _dump folder will be created, containing every dumped response. You can then analyze the result.

But I would suggest you try deploying the app with a proxy to avoid the restriction.

masterindex1 commented 2 weeks ago

I deployed to a different service and it worked. Thanks!