Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

I found this script online:

import httplib, urllib 

params = urllib.urlencode({'number': 12524, 'type': 'issue', 'action': 'show'}) 

headers = {"Content-type": "application/x-www-form-urlencoded",

 "Accept": "text/plain"} 

conn = httplib.HTTPConnection("") 

conn.request("POST", "", params, headers) 

response = conn.getresponse() 

print response.status, response.reason 

302 Found 

data = 


'Redirecting to <a href=""></a>' conn.close()

But I don't understand how to use it with PHP or what everything inside the params variable is or how to use it. Can I please have a little help with trying to get this to work?

1 Answer

0 votes
by (106k points)

To send the post request you can use the below-mentioned code:-

>>> import requests 

>>> r ="", data={'number': 12524, 'type': 'issue', 'action': 'show'}) 

>>> print(r.status_code, r.reason) 

200 OK 

>>> print(r.text[:300] + '...') 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 

<html xmlns="" xml:lang="en" lang="en"> 


<title> Issue 12524: change httplib docs POST example - Python tracker 


<link rel="shortcut i... 


Related questions

0 votes
1 answer
asked Oct 9, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 24, 2019 in Java by Nigam (4k points)

Browse Categories