使用自定义搜索引擎以PHP或JavaScript格式获取Google搜索结果

I'm trying to use the Google CSE, but I'm having no luck with it. Until now, I would use the Google Web Search API, and it worked great - but since this API is deprecated since 2010, I guess I'll have to go other ways.
So I read everywhere that I should use the Google Custom Search API instead, but I don't find a way to get results from Google with this, but only from websites with the given url. So how is it possible to search Google (without doing something illegal) in PHP or JavaScript (vanilla or node.js)?
Thank you!