JustalK / PORNHUB-API

A powerful and complete scrapper for the very famous pornhub.com. This javascript module for node give you the possibility, through an API with many options, to scrap any information out of a page or the search page.
MIT License
130 stars 29 forks source link

An error ocurred #26

Closed arugaz closed 3 years ago

arugaz commented 3 years ago

const pornhub = require('@justalk/pornhub-api'); const searchs = 'japan' pornhub.search(searchs,["title","link","premium","hd"]).then((result) => { const url = result.results[1].link.replace('.com//','.com/') console.log(url) pornhub.page(url, ["title","pornstars","download_urls"]).then((res) => { console.log(res) }) })

https://www.pornhub.com/view_video.php?viewkey=ph5f2469605d618 { error: 'An error occured' }

can not be in another link? but when searchs is 'Aa' it doesn't display an error

arugaz commented 3 years ago

sometimes it works, sometimes it doesn't work

JustalK commented 3 years ago

Hello,

You made me notice that the url return was not correct. So I fixed it. You can now remove the replace //com to /com

You also made me discover a bug, when there is no result for pornstars by example. My code was trying to sanitize a data that odes not exist. So I fixed that too.

Now, your code should work. I added your code to my unit test.

const result = await m.search('japan', ['title', 'link', 'premium', 'hd']);
const url = result.results[1].link;
const page = await m.page(url, ['title', 'pornstars', 'download_urls']);
arugaz commented 3 years ago

Hello,

You made me notice that the url return was not correct. So I fixed it. You can now remove the replace //com to /com

You also made me discover a bug, when there is no result for pornstars by example. My code was trying to sanitize a data that odes not exist. So I fixed that too.

Now, your code should work. I added your code to my unit test.

const result = await m.search('japan', ['title', 'link', 'premium', 'hd']);
const url = result.results[1].link;
const page = await m.page(url, ['title', 'pornstars', 'download_urls']);

thank you very much, i will ask again if there is a problem