I am trying to create a script to login to USPS website to get a list of incoming packages from Informed Delivery.
I have tried two methods:
- Requests
- Selenium
Requests
I captured the Login request and imported into Postman. When I sent request, I received error:
{
"actionErrors": [
"We have encountered an error. Please refresh the page and try again."
],
"actionMessages": [],
"fieldErrors": {}
}
In the request body, it sends a token value (from login form). The request headers also send a few headers starting with x-jfuguzwb-
. These look to be tokens of different values.
Selenium
Even using a headless browser didn't work.
LOGIN_URL = "https://reg.usps.com/entreg/LoginAction_input?app=Phoenix&appURL=https://www.usps.com/"
driver.get(LOGIN_URL)
username = driver.find_element_by_name('username')
username.send_keys(USERNAME)
password = driver.find_element_by_name('password')
password.send_keys(PASSWORD)
driver.find_element_by_id('btn-submit').click()
displays an error saying "Our apologies that you are having issues with your login."
There was a Python Module called myusps but it has not been updated for a couple years.
Are there any suggestions as to how I can accomplish this?