2

I try to send form data to the following url: https://peepoo.gq I have tried adding headers, and almost everything in the chrome network log that a normal browser sends, but I am always left with error 405. My code:

import requests

url = 'https://peepoo.gq/'

payload = {'content' : 'bruh'}

headers = {
'accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
'content-type' : 'application/x-www-form-urlencoded',
'accept-encoding' : 'gzip, deflate, br',
'accept-language' : 'en-US,en;q=0.9',
'cache-control' : 'max-age=0',
'content-length' : '12',
'dnt' : '1'
}

params = {'guestbook_name' : 'main'}

r = requests.post(url, data=payload, headers=headers, params=params, allow_redirects=False)


print(r)
3
  • The website does not accept POST requests to that URL or there's a redirect involved converting your post to a GET. Commented Feb 5, 2020 at 4:09
  • @KlausD. how can I circumvent this? I think it may be a redirect issue. I've disabled redirects, but this doesn't work. Commented Feb 5, 2020 at 4:10
  • What do/don't you understand from that status? Commented Feb 5, 2020 at 4:29

3 Answers 3

2

The following code is working for me:

import requests

url = 'https://peepoo.gq/sign'

payload = {'content' : 'pickle rick'}

headers = {
'content-type' : 'application/x-www-form-urlencoded',
}

params = {'guestbook_name' : 'main'}

r = requests.post(url, data=payload, headers=headers, params=params, allow_redirects=True)

basically, you need to allow redirects and your url needs to point to https://peepoo.gq/sign

Sign up to request clarification or add additional context in comments.

3 Comments

thank you for providing a solution! may I ask, how did you find the correct url to post to?
I just went to the website, opened the "developer tools" from chrome, navigated to the "network" tab, and then I posted a message. I noticed the url and also the redirects. :)
thank you! I was using the network log, but I must have missed that url. thanks again!
0

You are using a POST method what is not accepted (said already by Klaus D.) and using the data parameter, what passes the information to the POST method also.

Apart from that you are passing twice the following key value pair: 'guestbook_name' : 'main' Once in the url and once in the params.

Comments

0

I got 405 HTTP error, because of the default User-Agent: python-requests/2.27.1 header that requests module sends . Changing User-Agent header helped me:

import requests

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36'
}
url = 'https://example.com/some-path'
data = {'a': 1}

r = requests.post(url, data=data, headers=headers, allow_redirects=True)
print(r.status_code)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.