How to use wget http status codes in an if else statement to take an action based on the status code

You are printing the HTTP status code to the standard output but your code compares a return code from wget, not a value printed to standard output. If there is no error then wget returns 0.