import socket,sys
import os
import time
class A:
count=0
def __init__(self,name):
self.name =name
self.__class__.count+=1
def __del__(self):
print self.name
mysocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ret=mysocket.connect_ex(("passport.csdn.net",80))
if ret != 0:
print "error"
str="""GET /ajax/accounthandler.ashx?t=log&u=用户&p=密码&c=&remember=0&f=http%3A//passport.csdn.net/account/login HTTP/1.0
Host: passport.csdn.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept: */*rn
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Referer: http://passport.csdn.net/account/loginbox?callback=logined
Cookie: __utma=17226283.1766045922.1319848965.1319859470.1319867337.4; __utmz=17226283.1319859470.3.2.utmcsr=csdn.net|utmccn=(referral)|utmcmd=referral|utmcct=/; UN=FOXHENGXING; __message_sys_msg_id=1167; __message_gu_msg_id=0; __message_cnel_msg_id=0; __message_district_code=000000; __message_in_school=0; __utmb=17226283.8.10.1319867337; __utmc=17226283; LastVisitedForum=17673f58-331a-4f41-a240-3ac1d698fd74
"""
str+="\n\n"
mysocket.send(str)
str = mysocket.recv(2048)
while len(str)!=0:
print str
str = mysocket.recv(2048)
mysocket2=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ret=mysocket2.connect_ex(("www.csdn.net",80))
if ret != 0:
print "error"
str="""GET /postedit HTTP/1.0
Host: write.blog.csdn.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
rAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Referer: http://passport.csdn.net
Cookie:__utma=17226283.1766045922.1319848965.1319859470.1319867337.4; __utmz=17226283.1319859470.3.2.utmcsr=csdn.net|utmccn=(referral)|utmcmd=referral|utmcct=/; UN=FOXHENGXING; __message_sys_msg_id=1167; __message_gu_msg_id=0; __message_cnel_msg_id=0; __message_district_code=000000; __message_in_school=0; __utmb=17226283.4.10.1319867337; __utmc=17226283; UserName=FOXHENGXING; UserInfo=YasntZsVi4kbKtZNQ0KAvoApZO3dgaRFVgMw%2b%2bxXbF2PzlhC5uBbsqLtOYDqGk6thZK82BKTRhHW2mRSWXMbq%2b%2f2x1QHMCOsKY5XXPr1KU8nm1vdSCcngkAZXnSWtSyGC6HgpPeeR7jTI25wxIa3wGmgRS0pqc6ubDWqKpFlj4p78wKbvy3aoV6cMsHMUaTRLjQYaA8KQ83rEHIdVWRFLm9iJZnz6Qqi02Amk3IRgpQ%3d
"""
str+="\n\n"
print "---------------------------------------"
file = open ( r'd:\test3.html', 'w' )
mysocket2.send(str)
str = mysocket2.recv(2048)
file.write(str)
while len(str)!=0:
print "----wirte-----"
str = mysocket2.recv(2048)
file.write(str)
file.close()