x4nth055/pythoncode-tutorials

NoneType Object Not Iterable

HardikTilwani opened this issue · 3 comments

Traceback (most recent call last):
File "C:\Users\abc\PycharmProjects\Project1\venv\Scripts\new.py", line 60, in
data = get_video_info(url)
File "C:\Users\abc\PycharmProjects\Project1\venv\Scripts\new.py", line 34, in get_video_info
result["likes"] = int(''.join([c for c in text_yt_formatted_strings[0].attrs.get("aria-label") if c.isdigit()]))
TypeError: 'NoneType' object is not iterable

I am trying this script on a video where like and dislike are hidden, so how to retrieve it in this scenario - Help If Possible

Sorry Error Got Resolved By Adding

result["likes"] = text_yt_formatted_strings[0].int
# number of dislikes
result["dislikes"] = text_yt_formatted_strings[1].int

But Still I Got Value of like and dislike as None - As they are hidden so how to retrieve it even if they are hidden - Help :)

Hey there,
If it's hidden, I don't think there is a way to extract it, thanks for pointing out the error and I'll fix it soon.
Thanks!

No Problem - This Was Helpful Anyway - Thank You