question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blank json output for all searches

See original GitHub issue

I have been using this snippet for a while:

search = json.loads(YoutubeSearch("test", max_results=1).to_json())
videos = search["videos"][0]
link = videos["link"]
print("https://youtube.com" + link)

which now results in list index out of range

Since today, the json output appears to be returning this for all searches: {"videos": []}

I’m wondering if youtube changed something in the page?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
alexmercerindcommented, Jul 2, 2020

Now YouTube randomly returns two types of responses, one within JavaScript and other as HTML… Now we cannot scrape using BeautifulSoup.

I have separately written another script here completely from scratch (without any third party library) and is working with both types of responses.

Feel free to use: https://github.com/alexmercerind/youtube-search-python

It has lot more information in its search result.

2reactions
joetatscommented, Jun 30, 2020

All the video info is now contained inside a Javascript object within a script tag on the returned page, so the parser will need to collect from there. I’m testing out some javascript parsing libraries and hopefully will have something soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Check if JSON response data is empty - Stack Overflow
Try below code snippet:- if(!Object.keys(response.data).length){ console.log("no data found"); }. If you are getting data as empty object ...
Read more >
How to handle empty JSON response
At the bottom of the screenshot, I have a for each loop (which was automatically created) based on the 'customer' output of a...
Read more >
Solved: Re: Empty JSON string when getting target response...
I am receiving JSON string response from target endpoint with Content-Type as "text/plain; charset=UTF-8". Here is the RAW raw response from target endpoint....
Read more >
JSON REST API response with empty list - OutSystems
I'm producing a REST API with JSON response. In case the response is emtpy, the consumers like to get the following response: {....
Read more >
Solved: Can someone Explain why JSON returns empty unless
So to send it back into my client script I used JSON.stringify but it would always return "{}" or empty unless I use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found