Can we get user profile page using user_id in the URL?

You can use the get_the_author_meta() function for this purpose. Use the get_the_author_meta('ID') for only get the ID.

Ensure you check the page first with is_author() function before getting the ID.

https://developer.wordpress.org/reference/functions/get_the_author_meta/
https://developer.wordpress.org/reference/functions/is_author/