Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Python HTTP Post to Apache

Hello

I have a super simple python script requesting to HTTP post to one of my web pages with PHP script.

[CODE lang="python" title="Python"]import requests

url = 'https://domain.com/page.php'
myobj = {'test': '1'}

x = requests.post(url, data = myobj)

print(x.text)
[/CODE]

Here is the code on the server side:

[CODE lang="php" title="Server Side PHP Script"]<?php
print_r($_REQUEST);
?>[/CODE]

Based on what I've read this should be formatted correctly to send to my web page. But I keep getting the following back from my python script:

[CODE lang="html" title="HTML error"]<head><title>Not Acceptable!</title></head><body><h1>Not Acceptable!</h1><p>An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.</p></body></html>[/CODE]

The web page just displays Array(). Does anyone know what the issue could be?
 
Eum, do you have a VPN ahah?
** That is probably not your IP address if it works in your web browser.

I am really lost... Could it be a problem with PHP? Can you retrieve an HTML document?
 
I am seriously lost as to why the requests of your script are blocked... Since the requests of the script comes from the same IP address and same port as when you use your web browser, I do not know how the server detects the requests are from the script.
 
Oh, it may be that when your script sends requests, in the header, it indicates that they are from a script (The same way your navigator indicates that it is Firefox, Chrome..). 'Mod_Security' may block requests from software that are not web browsers.
 
You may be right though they may just be allowing scripts that are coming from specific browsers. HTTP requests are going through now so whatever they did it works. Just hope I don't run into this with every new IP I get.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom