Closed iced-queen closed 1 year ago
- Have you ever gotten this 403 before?
- Does Pornhub give you 403 every time?
video()
has always worked as expected. I think it started a little while after the random()
and recommendedVideos()
features came to the library.hmm so only recommendedVideos
get 403?
Does 1.7.0 also give you 403?
I feel I really should provide a verbose mode for debugging.
May I know you IP country? and can you test it with a non-EU VPN?
hmm so only
recommendedVideos
get 403?
No. They all do.
video()
: 403 Forbidden at https://www.pornhub.com/recommendedVideos()
: 403 Forbidden at https://www.pornhub.com/recommendedrandomVideo()
: 403 Forbidden at https://www.pornhub.com/randomsearchVideo()
function does not give any errors.Though also the pornstar()
and model()
functions gives 403 errors.
Does 1.7.0 also give you 403?
No, that gives me that empty result.
May I know you IP country? and can you test it with a non-EU VPN?
GB country IP address as that's where my VPS is located. And I do not have a VPN, sorry.
Ok, then I guess some cookies are invalid for GB users.
Can you try this code snippet? It will remove all cookies. And you can also play around by only removing cookies that you think suspicious to find out the one mess things up.
const pornhub = new PornHub();
(async () => {
const result = await pornhub.randomVideo()
console.log(result)
// remove all cookies
const cookies = pornhub.getCookies()
Object.keys(cookies).forEach(key => pornhub.deleteCookie(key))
const result2 = await pornhub.randomVideo()
console.log(result2)
})()
Ok, then I guess some cookies are invalid for GB users.
Can you try this code snippet? It will remove all cookies. And you can also play around by only removing cookies that you think suspicious to find out the one mess things up.
const pornhub = new PornHub(); (async () => { const result = await pornhub.randomVideo() console.log(result) // remove all cookies const cookies = pornhub.getCookies() Object.keys(cookies).forEach(key => pornhub.deleteCookie(key)) const result2 = await pornhub.randomVideo() console.log(result2) })()
I know literally nothing about cookies 😆
But I just tried and two videos returned as expected.
{
id: 'ph61a51f215c342',
url: 'https://www.pornhub.com/view_video.php?viewkey=ph61a51f215c342',
title: 'Perdiendo Mi Virginidad',
views: 1200,
vote: { up: 1, down: 0, total: 1, rating: 1 },
premium: false,
thumb: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
preview: 'https://di.phncdn.com/videos/202111/29/398856931/original/(m=eaAaGwObaaaa)(mh=NBxosUjEJytjunLg)12.jpg',
videos: [],
provider: { username: 'EVAALM12', url: '/model/evaalm12' },
tags: [ 'amateur', 'vaginal-fisting', 'latin' ],
pornstars: [],
categories: [
'Amateur',
'Exclusive',
'HD-Porn',
'Latina',
'Reality',
'Verified-Amateurs',
'Vertical-Video'
],
duration: 65,
durationFormatted: '01:05',
uploadDate: 2021-11-29T18:44:49.000Z
}
{
id: '63dc1ee7e09ac',
url: 'https://www.pornhub.com/view_video.php?viewkey=63dc1ee7e09ac',
title: 'Putita Pelirroja Se Masturba Con Helado y Se Chupa Las Tetas',
views: 0,
vote: { up: 0, down: 0, total: 0, rating: 0 },
premium: false,
thumb: '',
preview: 'https://ei.phncdn.com/videos/202302/02/424667391/original/(m=eaAaGwObaaaa)(mh=GEKmEXIjQ6Ek2tYh)8.jpg',
videos: [],
provider: null,
tags: [
'tattoo-girl',
'red-hair',
'ice-cream',
'girl-masturbating',
'cream',
'pussy',
'tits'
],
pornstars: [],
categories: [
'Feet',
'Female-Orgasm',
'Fetish',
'HD-Porn',
'Latina',
'Masturbation',
'Red-Head',
'Solo-Female',
'Toys',
'Verified-Amateurs',
'Vertical-Video',
'Webcam'
],
duration: 539,
durationFormatted: '08:59',
uploadDate: 2023-02-02T20:50:44.000Z
}
2 videos? wait, how come you get the first video without 403 🤣 Can you try to minimize the amount of cookies to remove?
I have noooo idea. 🤣 And again, I know literally nothing about cookies. 👀
I used to retry the process if res.id
was the normal pornhub url, which it used to be if the random endpoint failed. Idk if it still does that, but then I tried to remove that part and I only get the 403 error now when then trying to gain more information about the video with video()
So it only seems like the issue occurs when trying to gain more information about a video or pornstar/model (video()
, pornstar()
, model()
). The searching part doesn't seem to have it.
And again, I know literally nothing about cookies. 👀
Actually, you don't need to have knowledge about it. The simple steps is to print out all the cookies you have, pick 1~2 to the deletion list. And run again to check 403.
So it only seems like the issue occurs when trying to gain more information about a video or pornstar/model (video(), pornstar(), model()). The searching part doesn't seem to have it.
With the same code? or after deleting the cookie? because you said they all give you 403.
With the same code? or after deleting the cookie? because you said they all give you 403.
Without doing anything with cookies.
Regarding the cookies. I just tried to print out cookies
from getCookies()
and got:
{
platform: 'pc',
accessAgeDisclaimerPH: '1',
accessAgeDisclaimerUK: '1',
accessPH: '1',
age_verified: '1',
atatusScript: 'hide',
cookiesBannerSeen: '1',
hasVisited: 'deleted',
ss: '529247512768523837',
fg_0d2ec4cbd943df07ec161982a603817e: '40189.100000',
__s: 'deleted',
__l: 'deleted'
}
I have literally no idea what to do with that.
video(): 403 Forbidden at https://www.pornhub.com/ recommendedVideos(): 403 Forbidden at https://www.pornhub.com/recommended randomVideo(): 403 Forbidden at https://www.pornhub.com/random The searchVideo() function does not give any errors.
Can you list out the new behavior again?
And this is part of the purpose of cookies. Anyway.
video(): 403 Forbidden at https://www.pornhub.com/ recommendedVideos(): 403 Forbidden at https://www.pornhub.com/recommended randomVideo(): 403 Forbidden at https://www.pornhub.com/random The searchVideo() function does not give any errors.
Can you list out the new behavior again?
And this is part of the purpose of cookies. Anyway.
What do you mean "the new behavior" sorry?
@chocobearxo like this
Function | Without Removing Cookie | With Removing Cookie |
---|---|---|
video() |
200 OK | 200 OK |
recommendedVideos() |
200 OK | 200 OK |
randomVideo() |
403 Forbidden | 403 Forbidden |
searchVideo() |
200 OK | 200 OK |
Sorry but I'm not really experienced enough to check those things :/
I tried with the function you sent earlier with removing all the cookies.
(async () => {
const result = await pornhub.randomVideo()
console.log(result)
// remove all cookies
const cookies = pornhub.getCookies()
Object.keys(cookies).forEach(key => pornhub.deleteCookie(key))
const result2 = await pornhub.randomVideo()
console.log(result2)
})()
I don't really know how to make "tables" sorry.
1: Before removing cookies
2: After removing cookies
randomVideo()
: 1 (200 OK), 2 (200 OK)
recommendedVideos()
: 1 (200 OK), 2 (Empty results)
searchVideo()
: 1 (200 OK), 2 (Empty results)
I'm sorry, I really don't know how to help more
It still only really seems to the the video()
function that gives the 403 Forbidden error by the way. I hope it's something you can fix. :)
Actually the album()
function does this too. It seems to only cause this issue when trying to get pages, e.g. a video page or album page.
It also happens with pornstar()
and model()
. So those functions where you get info from a page are what's having issues.
So to give you a quick list:
video()
pornhub()
model()
album()
recommendedVideos()
does it too.And I bet photo()
does it too, but I haven't used that and don't plan to.
And I just tried to use clearCookies()
before getting recommended videos and instead of giving me a 403 Forbidden error, it just returned an empty result.
{ data: [], paging: { current: 1, maxPage: 1, isEnd: true } }
function clearCookies() {
const cookies = pornhub.getCookies()
Object.keys(cookies).forEach(key => pornhub.deleteCookie(key))
}
But clearing cookies before e.g. video()
doesn't have any effect.
Or the cause at least...
The issue is not regarding the actual video()
function. For example, first time I use the randomVideo()
function, it works fine. But if I then use it again without having restarted the bot, it "403"'s me again. So when I e.g. use the searchVideo()
function that requires me to use the video()
function afterwards in order to get the information I need, that'd be a 2nd "request" and would then gives me "403".
I just tried to use the video()
function as the first one before anything else after having my bot freshed out (restarted) and it worked. So clearly the issue isn't the actual function now, but rather any other requests after the first one.
Thanks for finding out that. I remembered that the only difference was the cookie. 😅 I will look into it if there is something else changing.
Thanks for finding out that. I remembered that the only difference was the cookie. 😅 I will look into it if there is something else changing.
Np, I hope you’re able to fix it soon! Do you think you’re able to today? 😄
By the way, I just tried having pornhub = new PornHub()
before every function/request, that still messed up and gave me "403". So either way it's just only the first request that works. 🤷♀️
Edit: Or if I use that pornhub = new PornHub()
every time the command is ran (so inside the module.exports
), the first request every time the command is ran works, but if I have it before every request, it doesn't. This is so odd lol
Sounds things are getting weird...
I will publish a new version with better logging. And let's see if we can find some pattern from your log.
Now you can install v1.7.3
and start the server with DEBUG=* && npm start
to see the detailed log.
REQUEST [Cookie] Received Set-Cookie: fg_fa3f0973fd973fc3dfabc86790b408b=88531.100000 +0ms
REQUEST [Cookie] Received Set-Cookie: __s=64EB7439-42FE722901B1857-33C75F06 +1ms
REQUEST [Cookie] Received Set-Cookie: __l=64EB7439-42FE722901B1857-33C75F06 +0ms
REQUEST [ RQST ] GET https://www.pornhub.com/view_video.php?viewkey=ph62f79e2ed1ed8 +736ms
REQUEST [ RESP ] GET https://www.pornhub.com/view_video.php?viewkey=ph62f79e2ed1ed8 200 OK +689ms
Now you can install
v1.7.3
and start the server withDEBUG=* && npm start
to see the detailed log.REQUEST [Cookie] Received Set-Cookie: fg_fa3f0973fd973fc3dfabc86790b408b=88531.100000 +0ms REQUEST [Cookie] Received Set-Cookie: __s=64EB7439-42FE722901B1857-33C75F06 +1ms REQUEST [Cookie] Received Set-Cookie: __l=64EB7439-42FE722901B1857-33C75F06 +0ms REQUEST [ RQST ] GET https://www.pornhub.com/view_video.php?viewkey=ph62f79e2ed1ed8 +736ms REQUEST [ RESP ] GET https://www.pornhub.com/view_video.php?viewkey=ph62f79e2ed1ed8 200 OK +689ms
What do you mean with DEBUG=* && npm start
? Haven't heard of that before 👀
@chocobearxo check this https://www.npmjs.com/package/debug, set DEBUG
env before your application startup command
@chocobearxo check this https://www.npmjs.com/package/debug, set
DEBUG
env before your application startup command
Still not really sure what you want me to do? 😅
Hmm ok. What platform were you developing? Windows / Mac? And what's the command that you start your bot or test this library?
Windows. I just run the bot in a CMD node ./src/index.js
.
Also, I just changed all the debug
s to console.log
s in the library, which gave me this:
[Header] Set: Host=www.pornhub.com
[Header] Set: Origin=https://www.pornhub.com
[Header] Set: Referer=https://www.pornhub.com/
[Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
[Cookie] Set: platform=pc
[Cookie] Set: accessAgeDisclaimerPH=1
[Cookie] Set: accessAgeDisclaimerUK=1
[Cookie] Set: accessPH=1
[Cookie] Set: age_verified=1
[Cookie] Set: atatusScript=hide
[Cookie] Set: cookiesBannerSeen=1
[Cookie] Set: hasVisited=1
[Header] Set: Host=www.pornhub.com
[Header] Set: Origin=https://www.pornhub.com
[Header] Set: Referer=https://www.pornhub.com/
[Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
[Cookie] Set: platform=pc
[Cookie] Set: accessAgeDisclaimerPH=1
[Cookie] Set: accessAgeDisclaimerUK=1
[Cookie] Set: accessPH=1
[Cookie] Set: age_verified=1
[Cookie] Set: atatusScript=hide
[Cookie] Set: cookiesBannerSeen=1
[Cookie] Set: hasVisited=1
[Header] Set: Host=www.pornhub.com
[Header] Set: Origin=https://www.pornhub.com
[Header] Set: Referer=https://www.pornhub.com/
[Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
[Cookie] Set: platform=pc
[Cookie] Set: accessAgeDisclaimerPH=1
[Cookie] Set: accessAgeDisclaimerUK=1
[Cookie] Set: accessPH=1
[Cookie] Set: age_verified=1
[Cookie] Set: atatusScript=hide
[Cookie] Set: cookiesBannerSeen=1
[Cookie] Set: hasVisited=1
Don't know if it's any useful to you, but there it is. 😄
(I guess the reason why it logged 3 times is because I got new PornHub()
in 3 files.)
I just tried the searchVideo()
function which then gave me:
[ RQST ] GET https://www.pornhub.com/video/search?search=latina%2Bass
[ RESP ] GET https://www.pornhub.com/video/search?search=latina%2Bass 200 OK
Redirected from https://www.pornhub.com/video/search?search=latina%2Bass to https://www.pornhub.com/video/search?search=latina+ass
[Cookie] Received Set-Cookie: ss=866610152423605780
[Cookie] Received Set-Cookie: fg_0d2ec4cbd943df07ec161982a603817e=27513.100000
[Cookie] Received Set-Cookie: hasVisited=deleted
[Cookie] Received Set-Cookie: hasVisited=deleted
[Cookie] Received Set-Cookie: __s=deleted
[Cookie] Received Set-Cookie: __s=deleted
[Cookie] Received Set-Cookie: __l=deleted
[Cookie] Received Set-Cookie: __l=deleted
[Cookie] Received Set-Cookie: fg_9951ce1ac4434b4ac312a1334fa77d82=23712.100000
[Cookie] Received Set-Cookie: fg_5067492b57c1c879a31bcb2ab72b7a3b=95002.100000
[Cookie] Received Set-Cookie: fg_7eb5e6299ee952620df104ed2e7aac86=3179.100000
And then after the video()
function which then gave me:
[ RQST ] GET https://www.pornhub.com/
[ RESP ] GET https://www.pornhub.com/ 403 Forbidden
You can run set DEBUG=* & node ./src/index.js
I noticed that you got deleted
cookies 🤔 which is unusual.
And they are double printing.... curious...
One thing that I think can be done is better cookie expire handling.
You can run
set DEBUG=* & node ./src/index.js
I noticed that you got
deleted
cookies 🤔 which is unusual. And they are double printing.... curious...One thing that I think can be done is better cookie expire handling.
Alright so when loading up the bot, I got this:
REQUEST [Header] Set: Host=www.pornhub.com +0ms
REQUEST [Header] Set: Origin=https://www.pornhub.com +3ms
REQUEST [Header] Set: Referer=https://www.pornhub.com/ +0ms
REQUEST [Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 +1ms
REQUEST [Cookie] Set: platform=pc +0ms
REQUEST [Cookie] Set: accessAgeDisclaimerPH=1 +0ms
REQUEST [Cookie] Set: accessAgeDisclaimerUK=1 +1ms
REQUEST [Cookie] Set: accessPH=1 +0ms
REQUEST [Cookie] Set: age_verified=1 +0ms
REQUEST [Cookie] Set: atatusScript=hide +0ms
REQUEST [Cookie] Set: cookiesBannerSeen=1 +1ms
REQUEST [Cookie] Set: hasVisited=1 +0ms
REQUEST [Header] Set: Host=www.pornhub.com +467ms
REQUEST [Header] Set: Origin=https://www.pornhub.com +1ms
REQUEST [Header] Set: Referer=https://www.pornhub.com/ +0ms
REQUEST [Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 +0ms
REQUEST [Cookie] Set: platform=pc +0ms
REQUEST [Cookie] Set: accessAgeDisclaimerPH=1 +1ms
REQUEST [Cookie] Set: accessAgeDisclaimerUK=1 +0ms
REQUEST [Cookie] Set: accessPH=1 +0ms
REQUEST [Cookie] Set: age_verified=1 +0ms
REQUEST [Cookie] Set: atatusScript=hide +1ms
REQUEST [Cookie] Set: cookiesBannerSeen=1 +0ms
REQUEST [Cookie] Set: hasVisited=1 +0ms
REQUEST [Header] Set: Host=www.pornhub.com +286ms
REQUEST [Header] Set: Origin=https://www.pornhub.com +1ms
REQUEST [Header] Set: Referer=https://www.pornhub.com/ +2ms
REQUEST [Header] Set: User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 +1ms
REQUEST [Cookie] Set: platform=pc +1ms
REQUEST [Cookie] Set: accessAgeDisclaimerPH=1 +0ms
REQUEST [Cookie] Set: accessAgeDisclaimerUK=1 +1ms
REQUEST [Cookie] Set: accessPH=1 +1ms
REQUEST [Cookie] Set: age_verified=1 +0ms
REQUEST [Cookie] Set: atatusScript=hide +1ms
REQUEST [Cookie] Set: cookiesBannerSeen=1 +1ms
REQUEST [Cookie] Set: hasVisited=1 +0ms
Also the double printing is because I got new PornHub()
in 3 files. 😄
The startup looks ok. Can you trigger some 403 with one instance? I want to check the full debug log.
The startup looks ok. Can you trigger some 403 with one instance? I want to check the full debug log.
Want me to use a command that first uses the searchVideo()
function and then video()
?
yes
So searchVideo()
which was the first function:
REQUEST [ RQST ] GET https://www.pornhub.com/video/search?search=latina%2Bass +7m
REQUEST [ RESP ] GET https://www.pornhub.com/video/search?search=latina%2Bass 200 OK +260ms
REQUEST Redirected from https://www.pornhub.com/video/search?search=latina%2Bass to https://www.pornhub.com/video/search?search=latina+ass +0ms
REQUEST [Cookie] Received Set-Cookie: ss=564753819636593988 +1ms
REQUEST [Cookie] Received Set-Cookie: fg_0d2ec4cbd943df07ec161982a603817e=45836.100000 +0ms
REQUEST [Cookie] Received Set-Cookie: hasVisited=deleted +1ms
REQUEST [Cookie] Received Set-Cookie: hasVisited=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: __s=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: __s=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: __l=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: __l=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: fg_9951ce1ac4434b4ac312a1334fa77d82=91602.100000 +1ms
REQUEST [Cookie] Received Set-Cookie: fg_5067492b57c1c879a31bcb2ab72b7a3b=97634.100000 +0ms
REQUEST [Cookie] Received Set-Cookie: fg_7eb5e6299ee952620df104ed2e7aac86=4250.100000 +0ms
And the video()
function which was right after:
REQUEST [ RQST ] GET https://www.pornhub.com/ +855ms
REQUEST [ RESP ] GET https://www.pornhub.com/ 403 Forbidden +31ms
Can you try add an await pornhub.warmup()
before the searchVideo call
Can you try add an
await pornhub.warmup()
before the searchVideo call
Would it matter if I added that as the first thing in the command (which means I'd run once every time the command was used)?
Oh, I got some idea. Passing deleted
to PH server will cause 403.
And that cookie should have an expire that needs to be followed by the library, as I mentioned in previous replies.
Ofc getting deleted
is still weird, but I think now things started to get clear.
Can you try add an
await pornhub.warmup()
before the searchVideo callWould it matter if I added that as the first thing in the command (which means I'd run once every time the command was used)?
it's ok~
`warmup` has been deprecated. You can safely remove this method call. It has been handled internally.
REQUEST [ RQST ] GET https://www.pornhub.com/video/search?search=latina%2Bass +3s
REQUEST [ RESP ] GET https://www.pornhub.com/video/search?search=latina%2Bass 200 OK +175ms
REQUEST Redirected from https://www.pornhub.com/video/search?search=latina%2Bass to https://www.pornhub.com/video/search?search=latina+ass +1ms
REQUEST [Cookie] Received Set-Cookie: ss=641093521578893720 +3ms
REQUEST [Cookie] Received Set-Cookie: fg_0d2ec4cbd943df07ec161982a603817e=2378.100000 +2ms
REQUEST [Cookie] Received Set-Cookie: hasVisited=deleted +1ms
REQUEST [Cookie] Received Set-Cookie: hasVisited=deleted +1ms
REQUEST [Cookie] Received Set-Cookie: __s=deleted +2ms
REQUEST [Cookie] Received Set-Cookie: __s=deleted +1ms
REQUEST [Cookie] Received Set-Cookie: __l=deleted +0ms
REQUEST [Cookie] Received Set-Cookie: __l=deleted +1ms
REQUEST [Cookie] Received Set-Cookie: fg_9951ce1ac4434b4ac312a1334fa77d82=51603.100000 +1ms
REQUEST [Cookie] Received Set-Cookie: fg_5067492b57c1c879a31bcb2ab72b7a3b=13075.100000 +1ms
REQUEST [Cookie] Received Set-Cookie: fg_7eb5e6299ee952620df104ed2e7aac86=16827.100000 +3ms
{
title: 'I snuck out to fuck my thick busty Teen cum slut. I came 4 times on that fat ass!',
id: 'ph5f7ea5d741d80',
url: 'https://www.pornhub.com/view_video.php?viewkey=ph5f7ea5d741d80',
views: '5.8M',
duration: '14:44',
hd: false,
premium: false,
freePremium: false,
preview: 'https://di.phncdn.com/videos/202010/08/358872942/thumbs_8/(m=eafTGgaaaa)(mh=VqFljCvJgHGIKvLw)2.jpg'
}
REQUEST [ RQST ] GET https://www.pornhub.com/ +543ms
REQUEST [ RESP ] GET https://www.pornhub.com/ 403 Forbidden +12ms
HttpStatusError: 403 Forbidden at https://www.pornhub.com/
So this logged when I had warmup there.
Which I made a search, then it logs a random result, and then I use video()
.
Wait lol, my bad, warmup
is now useless. Sorry.
Let me fix the cookie issue tmr.
Wait lol, my bad,
warmup
is now useless. Sorry.Let me fix the cookie issue tmr.
Alright, cool! 😄
But I still suspect that your ip might be flagged or something.
Gave me an error:
Error: 403 Forbidden at https://www.pornhub.com/
.res
returned:(I'm on v1.7.1)