Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:41:41+00:00 2026-06-04T04:41:41+00:00

The following python script works fine: #!/usr/bin/env python import httplib, urllib params = urllib.urlencode({‘url’:’xxx/xxx/0AAAUw7n6qPQ922.jpg’,

  • 0

The following python script works fine:

#!/usr/bin/env python
import httplib, urllib
params = urllib.urlencode({'url':'xxx/xxx/0AAAUw7n6qPQ922.jpg', 'key': 'xxxx'})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/html"}
conn = httplib.HTTPConnection("xxx.test.com")
conn.request("POST", "/xx/delete", params, headers);
response = conn.getresponse()
print response.status, response.reason
data = response.read()
print data
conn.close()

But if I want to reuse the open http connection to run post more times, it doesn’t work:

#!/usr/bin/env python
import httplib, urllib
import sys

if len(sys.argv)<2:
  print "invalid input"
  sys.exit(0)

path = sys.argv[1]
f = open(path)
lines = f.readlines()
f.close()

conn = httplib.HTTPConnection("xxx.test.com")
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/html"}
for line in lines:
  if len(line) < 6:
    continue
  params = urllib.urlencode({'url': line, 'key': 'xxxx'})
  conn.request("POST", "/xx/delete", params, headers);
  response = conn.getresponse()
  print response.status, response.reason
  data = response.read()
  print data
conn.close()

The return status is: 500 Server Error

I Just want to reuse the http connection to increase performance, how can I fixed this issue?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:41:42+00:00Added an answer on June 4, 2026 at 4:41 am

    Remove the newline character (‘\n’) in the string. It works fine!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the following little Python script: #!/usr/local/bin/python2.5 import sys, subprocess child
I have written following script in python which works fine: from sys import argv
I have the following python script and it works beautifully. import urllib2 url =
I wrote the following script, which generates a SyntaxError : #!/usr/bin/python print Enter the
I have following script: #!/usr/bin/python while True: x = raw_input() print x[::-1] I am
I am trying to execute a simple git command using following python script. #!/usr/bin/python
I have the following script for sending mails using python import smtplib from email.mime.multipart
I created a Python script with Python2.7 and it works fine. However, when I
The following works fine on Mac OS X: #!/bin/bash R CMD Sweave myfile.Rnw pdflatex
i have an activation mail sending script as follows. #!/usr/bin/python __author__ = 'Amyth Arora

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.