转: curl命令详解

April 7th, 2016

对于windows用户如果用Cygwin模拟unix环境的话,里面没有带curl命令,要自己装,所以建议用Gow来模拟,它已经自带了curl工具,安装后直接在cmd环境中用curl命令就可,因为路径已经自动给你配置好了。

linux curl是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称url为下载工具。
Read the rest of this entry »

Python网络编程基础 shutdown.py

March 18th, 2016

#!/usr/bin/env python
# Error Handling Example With Shutdown – Chapter 2 – shutdown.py

import socket, sys, time
host = sys.argv[1]
textport =sys.argv[2]
filename = sys.argv[3]
Read the rest of this entry »

Python网络编程基础 socketerrors.py

March 8th, 2016
#!/usr/bin/evn python
# Error Handling Example - Chapter 2 - socketerrors.py

import socket, sys
host = sys.argv[1]
textport = sys.argv[2]
filename = sys.argv[3]
 Read the rest of this entry »

Python网络编程基础 connect3.py

March 7th, 2016
#!/usr/bin/evn python
# Information Example - Charpter 2 -connect3.py

import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Done."

print "Looking up port number...",
port = socket.getservbyname('http','tcp')
print "Done."

print "Connecting to remote host on port %d..." % port,
s.connect(("www.google.com", port))
print "Done."

print "Connected from", s.getsockname()
print "Connected to", s.getpeername()

Python网络编程基础 connect2.py

March 4th, 2016
#!/usr/bin/env python
# Revised Connection Example - Chapter 2 - connect2.py
# Note please do run this code on Linux, not Windows platform
import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print "Done."

print "Looking up port number...",
port = socket.getservbyname('http', 'tcp')
print "done."

print "Connecting to remote host on port %d..." %port,
s.connect(("www.google.com", port))

print "done."


Python网络编程基础 connect.py

March 3rd, 2016
#!/usr/bin/env python
# Basic Connection Example - Chapter 2 - connect.py

import socket

print "Creating socket...",

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

print "done."

print "Connecting to remote host...",

s.connect(("www.google.com", 80))

print "done."

Python网络编程基础 download.py

February 24th, 2016
#!/usr/bin/env python
# Chapter 1 - Download Example - download.py

import urllib, sys
f = urllib.urlopen(sys.argv[1])

while 1:
    buf = f.read(2048)
    if not len(buf):
        break
    sys.stdout.write(buf)

Python网络编程基础 urlclient.py

February 24th, 2016
#!/usr/bin/env python
# High-Level Gopher Client with urllib - Chapter 1 - urlclient.py

import urllib, sys
host = sys.argv[1]
file = sys.argv[2]

f = urllib.urlopen('gopher://%s%s' % (host, file))
for line in f.readlines():
    sys.stdout.write(line)

Python网络编程基础 server.py

February 24th, 2016
#!/usr/bin/env python
# Simple Server - Chapter 1 -server.py
import socket

host = ''
port = 51423

Read the rest of this entry »

Python网络编程基础 gopherclient3.py

February 22nd, 2016
#!/usr/bin/env python
# Simple Gopher Client with file-like interface - Chapter 1
# gopherclient3.py

import socket, sys
port = 70
host = sys.argv[1]
filename = sys.argv[2]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
fd = s.makefile('rw',0)
fd.write(filename + "\r\n")
for line in fd.readline():
    sys.stdout.write(line)