Escape the url before opening. Moved url open to a separate method.