how to send http request without urlencode? - python

I am doing a Scan work,and Need to send http requests without urlencode. The web application use $_SERVER['REQUEST_URI'](php) to get URL, and I must use "<" or ">" to do my scan work. But python requests will encode ">" to "%3E". Is there any way to send http request without urlencode(requests, urllib, urllib2), except sending http requests using socket?
Firstly, I use requests to do it:
import requests
requests.get("http://test.com/index.php?id=1 and 1>1")
But the truth url the requests get is: http://test.com/index.php?id=1 and 1%3E1
This question has confused me for days, I'll be very happy to get any solution from you, and thanks all.

You can pass string parameters using the params argument. Like this:
requests.get("http://test.com/index.php", params="id=1 and 1>1")

Related

What does 'requests.head()' do in python requests?

import requests
send = requests.head('https://httpbin.org')
print(send.text)
What does 'requests.head()' do ? i get empty responses
A head request is a request used when you do not actually need the page content - just the status-code of your connection with the site or http-headers.

How to keep url encoded characters in requests in Python

I want to create a POST request to a site like mydomain.com?character=%61 using Requests library.
But if I use requests.post(url) with url = 'mydomain.com?character=%61' then it sends a POST request to mydomain.com?character=a. How can I keep %61 in request instead of decoding it to a?
Thanks all!

How to send CoAP requests with Python?

Is there a way to send CoAP requests, like HTTP requests, using Python. I tried below one but I got many errors.
rec = reuest.get(coap://localhost:5683/other/block)
You can use a library such as CoAPython to act as a CoAP client:
from coapthon.client.helperclient import HelperClient
client = HelperClient(server=('127.0.0.1', 5683))
response = client.get('other/block')
client.stop()
The response is of type Response. The methods available on the response are listed in the documentation, which you must build yourself.
Since you haven't listed what you want to do with the response, you can use the documentation to find out the methods available and get the values you want.

Python: get json data from https url using sockets

I need to get some json data using API
import requests
url = 'https://example.com/api/some-info/'
response = requests.get(url)
print(response.text) # Here is JSON needeed
And everything fine, except I need to make such requests very often, and API provider says:
You'll be banned if you make more than 5 requests per second, so use
sockets
So, how can I make this work via sockets?
Big thx for advices.

python changing headers

how do i change my headers and request so that i appear as firefox ...
like when request to some servers
import urllib
f = urllib.urlopen("rss feed")
they deny my request saying your client dosent have permission...
i get reply but the reply contains " your client dosent have permission"
so how do i get around this and get the data...
http://vsbabu.org/mt/archives/2003/05/27/urllib2_setting_http_headers.html
If you want to use good old urllib instead of newer, fancier urllib2, then as urllib's docs say, and I quote,
For example, applications may want to specify a different User-Agent header than URLopener defines. This can be accomplished with the following code:
import urllib
class AppURLopener(urllib.FancyURLopener):
version = "App/1.7"
urllib._urlopener = AppURLopener()
Of course, you'll want a version (aka User-Agent header) suitable for whatever version of Firefox (or w/ever else;-) you want to pretend you are;-).

Categories

Resources