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

can you help me? #21

Closed arugaz closed 3 years ago

arugaz commented 3 years ago

const pornhub = require('@justalk/pornhub-api'); const video = pornhub.search("Aa",["title","link","premium","hd"]); console.log(video.title)

i got undefinied

JustalK commented 3 years ago

Sorry, I did not see your message earlier. I have taken note of the bug.

I will check tomorrow and hopefully, it will be fixed by October 24 2020 ;)

JustalK commented 3 years ago

Ok, I got a bit curious since travis did not update me for telling me there is a bug in the API. So actually, the error you are facing is not due to the API but the way you use it. Maybe I did not explain it well in the documentation. I will work on that when I have time.

So the problem is the search functions return an array of objet. Not a single object, so your code should be if you wanna get the title of the first video :

const pornhub = require('@justalk/pornhub-api');
const video = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(video[0].title)

You should try the console.log on the response from the api ;)

const pornhub = require('@justalk/pornhub-api');
const results = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(results)

Tell me if any other questions or problem. I am often on github

arugaz commented 3 years ago

Ok, I got a bit curious since travis did not update me for telling me there is a bug in the API. So actually, the error you are facing is not due to the API but the way you use it. Maybe I did not explain it well in the documentation. I will work on that when I have time.

So the problem is the search functions return an array of objet. Not a single object, so your code should be if you wanna get the title of the first video :

const pornhub = require('@justalk/pornhub-api');
const video = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(video[0].title)

You should try the console.log on the response from the api ;)

const pornhub = require('@justalk/pornhub-api');
const results = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(results)

Tell me if any other questions or problem. I am often on github

i did but i got promise pending

arugaz commented 3 years ago

Ok, I got a bit curious since travis did not update me for telling me there is a bug in the API. So actually, the error you are facing is not due to the API but the way you use it. Maybe I did not explain it well in the documentation. I will work on that when I have time. So the problem is the search functions return an array of objet. Not a single object, so your code should be if you wanna get the title of the first video :

const pornhub = require('@justalk/pornhub-api');
const video = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(video[0].title)

You should try the console.log on the response from the api ;)

const pornhub = require('@justalk/pornhub-api');
const results = pornhub.search("Aa",["title","link","premium","hd"]);
console.log(results)

Tell me if any other questions or problem. I am often on github

i did but i got promise pending

nvm i got a solution, thank you very much for your time

JustalK commented 3 years ago

When you have a promise, use the await ;) Like this :

async () => {
   const pornhub = require('@justalk/pornhub-api');
   const results = await pornhub.search("Aa",["title","link","premium","hd"]);
   console.log(results)
}