need help, pyhon, url, var, post, error, socket

This is the place for queries that don't fit in any of the other categories.

need help, pyhon, url, var, post, error, socket

Postby Mr. Scanner » Sun Apr 07, 2013 11:59 am

import urllib
import urllib2
import os
import time

my_server = '#mywebsitehere'

def postSmallData(data):
postthis = "/uURLvar.php?upload="+urllib.quote(str(data))
conn = httplib.HTTPConnection(my_server)
conn.request("POST", postthis)
conn.close()

def ss2(string,BlockLength):
start = 0
end = BlockLength
loop = True
p = 0
while loop:
postSmallData(string[start:end])
start += BlockLength
end += BlockLength
'''
#a delayer , thought may get the job done :(
p += 1
if p == 160:#for server to wait
p = 0
time.sleep(10)
'''
if start > len(string): loop = False

a = open('largefile.7z','rb').read().encode('hex')
ss2(a, 4000)#this post data to php 4000 byte one post

#it works only for small bytes ~12kb max i think

#when i post something larger ex: 600kb, get an socket error, WHAT TO DO?
#i want to use URL var post as an file uploader with php.
#any recomandation?
#thanks
Mr. Scanner
 
Posts: 1
Joined: Sun Apr 07, 2013 11:48 am

Re: need help, pyhon, url, var, post, error, socket

Postby Yoriz » Sun Apr 07, 2013 2:27 pm

Hi,

Please could you edit your code to include code tags so the indention is correct.
Please read the following link on how to ask questions/post your code.
http://python-forum.org/viewtopic.php?f=10&t=145
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 781
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: snippsat, W3C [Linkcheck] and 3 guests