L'errore è autoesplicativo:
400 Bad Request

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
Un modo migliore per fare quello che vuoi fare è utilizzare get_headers() e controllare lo status code della risposta. Se è 404 allora non esiste.