#-- coding:utf8 --
#!/usr/bin/env python
#login
import time
import requests
import sys
import sys
import json
import re
import threading
from bs4 import BeautifulSoup
reload(sys)
sys.setdefaultencoding('gbk')
s=requests.Session()
#login
def login():
auth_url = "http://www.xinxianwang.com/login/login.asp"
values = {
"username":"****",
"password":"******",
"k":"Fri Oct 23 2015 23:39:12 GMT+0800 (中国标准时间)40000"
}
post_header ={
"Referer":"http://www.xinxianwang.com/login",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
"Accept-Encoding":"gzip, deflate",
"Accept-Language":"zh-CN,zh;q=0.8",
"Connection":"keep-alive"
}
mm = s.post(auth_url, data=values,headers=post_header).content
return mm
def reply(topid):
t=u"本群是新县最大的真实、严肃的单身交友群。本群的人员主要都是优秀的,素质高、学历高的新县单身男女。入群条件:1. 必须是单身。 2. 男20岁以上,女20岁以上适婚年龄。3. 在新县或者外地有稳定的工作。 4. 相信爱情,感情专一。 5. 以结婚为前提找对象,严肃!缘来如此1号群 99433323".encode("gbk")
replyvalues={
"title":"12332333",
"ccooeditor":str(t),
"setsign":1,
"action":"save",
"boardid":"126627",
"topicid":topid,
"page":3,
"InfoID":6
}
fromdata={
"postcontent":str(t),
"auto":1
}
print s.post("http://www.xinxianwang.com/forum/reply.asp",data=replyvalues).content
#result topid
def result_topid():
request=requests.get("http://www.xinxianwang.com/forum/today-1-1.html").content
# print request
topid=re.findall(r'thread-[0-9]+',request)
for id in topid:
topid=int(id.split("-")[1])
print topid
reply(topid)
time.sleep(10)
def main():
mm=login()
if int(mm)==1:
print "login success"
result_topid()
main()
具体代码已经开源。具体思路就是通过chrome浏览器抓到post的参数。然后post具体的值就可以了。