1

If I wanted to send post request to a website with my username and password data manually via a python function. Is it possible? If so what would some example code be.

Below is some half-assed code as I have no experience with http requests:

import requests
payload = {"username":"anton","password":"password"}

r = requests.post('https://www.walmart.com/account/login', data = payload)

print(r.text)
Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
  • 3
    Does this answer your question? [What is the cleanest way to do HTTP POST with basic auth in Python?](https://stackoverflow.com/questions/6256126/what-is-the-cleanest-way-to-do-http-post-with-basic-auth-in-python) – frederikwillersinn Apr 13 '21 at 08:50

1 Answers1

1

This should do the job:

import requests

url = "your_url"
r = requests.post(url, auth=("your_username", "your_password"))

print(r.text)

See requests docs for more information.