That is actually working , but you are overwriting it..
As you can see your final <a>
href does not contain the text imdb , so that will be overwritten by your previously found result by your else
statement.
Well how to fix it ?
Just remove the else
part from your code.