My URL is not taking '#' as input parameter | Flask

I've exposed a flask API which automates the submission of attendance using selenium script.

Students are supposed to send their id and pwd as parameters as shown below:

 mylink.com/?id=MyId&pwd=MyPassword@#

When I print and check the result, it is showing password as "MyPassword@" hence I'm not getting the desired output of the script. I do not understand why it eliminated "#" character.

Can someone helpme out. Thanks inadvance.

FYI, I have taken input using:

param1=str(request.args.get('pwd',default=""))

Tried removing str() from above, still getting the same bug.

Upvotes: 0

Views: 23

Answers (2)

PDHide
PDHide

Reputation: 19989

few special characters have special meanings in url, so have to be escaped by url encoding them in url:

import urllib.parse

print(urllib.parse.quote("pass#"))
pass = urllib.parse.quote(password);
driver.get(f"mylink.com/?id=MyId&pwd={pass}")

Upvotes: 0

The browser will strip any # character. Replace # with %23 as defined in the encoding scheme. You can get a copy here.

Upvotes: 0

Related Questions