egbertbouman / youtube-comment-downloader

Simple script for downloading Youtube comments without using the Youtube API
MIT License
885 stars 223 forks source link

Error: Document is empty #45

Closed khiemnd5 closed 4 years ago

khiemnd5 commented 4 years ago

I had problem when run code: Link example youtube: https://www.youtube.com/watch?v=sMAVhkFEeRw image

Do you have any idea? Thank you so much!

spiralofhope commented 4 years ago

It works for me using the latest version from git (ec268fd077c438093c4be1d8b000b90dde03f2ab). I don't think you are using the same version, because I don't see the timer. Update your copy from git and see if that helps.

./downloader.py --youtubeid sMAVhkFEeRw --output demo.json
Downloading Youtube comments for video: sMAVhkFEeRw
Downloaded 15 comment(s)
[1.39 seconds] Done!

(If you need to, I can provide the comments for any videos you need until you can solve your problem.)

khiemnd5 commented 4 years ago

@spiralofhope thank you reply me. I was checked. In python version 3.7 not working. Version 2.7 worked.

python3 downloader.py --youtubeid sMAVhkFEeRw --output demo.json Downloading Youtube comments for video: sMAVhkFEeRw Error: Document is empty

python downloader.py --youtubeid sMAVhkFEeRw --output demo.json Downloading Youtube comments for video: sMAVhkFEeRw Downloaded 15 comment(s) [1.69 seconds] Done!

image

I don't know why this problem. I was debugged the problem exception in this function.

def extract_reply_cids(html):
    tree = lxml.html.fromstring(html)
    sel = CSSSelector('.comment-replies-header > .load-comments')
    return [i.get('data-cid') for i in sel(tree)] 

I provided more info.

d0tN3t commented 4 years ago

@khiemnd5 I'm running 3.7 and I was able to download it as well.

Screen Shot 2020-07-31 at 1 45 25 AM

Maybe it has to do with your lxml package if you debugged it to that code block you showed. My lxml version is 4.2.5. But I can't see that being the reason as I've used different ones in the past. If you can get it to work with 2.7 then my guess is that your python 3 environments may be conflicting for some reason. Possibly other packages. You could try setting up a new environment with all the packages needed to run the script.

Screen Shot 2020-07-31 at 1 55 07 AM

d0tN3t commented 4 years ago

@egbertbouman I'm not sure if this is ready to be closed. I haven't received any feedback nor am I able to reproduce the error the user is receiving. 👍

egbertbouman commented 4 years ago

@d0tN3t I've just tried it using Python 2.7/3.7/3.8, but couldn't reproduce it either. So, I'll close this issue for now. If we get more similar reports, I'll take another, closer look.