91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Python實現某論壇自動簽到功能

發布時間:2020-10-03 03:28:29 來源:腳本之家 閱讀:234 作者:IT白鴿 欄目:開發技術

1.[文件] DakeleSign.py ~ 4KB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'poppy'
'''
dakele bbs sigin
'''
import sys
import urllib2
import urllib
import requests
import cookielib
import json
from pyquery import PyQuery as pq
import logging
logging.basicConfig(level=logging.DEBUG)
reload(sys)
sys.setdefaultencoding("utf8")
class Dakele(object):
  def __init__(self,name,password):
    self.name = name
    self.password = password
    self.cj = cookielib.LWPCookieJar()
    self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
    urllib2.install_opener(self.opener)
  def _getHeaders(self):
    headers = {}
    headers['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
    #headers['Host']='www.dakele.com'
    headers['Connection']='keep-alive'
    headers['Cache-Control']='max-age=0'
    headers['Accept-Language']='zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4'
    #headers['Accept-Encoding']='gzip, deflate, sdch'
    headers['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
    return headers
  def login(self):
    '''登錄網站'''
    logging.debug(u'正在登陸 username : %s password : %s' %(self.name,self.password))
    logging.debug(u'headers is : %s' % self._getHeaders())
    loginparams = {'product': 'bbs','surl': r'http://bbs.dakele.com/','username': self.name,'password':self.password,'remember':'0'}
    logging.debug(u'loginparams is : %s' % loginparams)
    req = urllib2.Request( r'http://passport.dakele.com/logon.do', urllib.urlencode(loginparams), headers=self._getHeaders())
    response = urllib2.urlopen(req)
    self.operate = self.opener.open(req)
    thePage = response.read()
    result = json.loads(thePage)
    return result['redirect']
  def login_bbs(self,url):
    '''登錄bbs網站'''
    logging.debug( 'start bbs login : %s ' % url)
    req = urllib2.Request(url,headers=self._getHeaders())
    response = urllib2.urlopen(req)
    self.operate = self.opener.open(req)
    thePage = response.read()
    #print thePage
  def _say(self,html):
    d = pq(html)
    s_action = d("#qiandao").attr("action")
    if s_action:
      s_formhash = d("#qiandao input[name=formhash]").attr("value")
      s_qdxq = d("#qiandao input[name=qdxq]").attr("value")
      s_qdmode = '1'
      loginparams = {'formhash':s_formhash,'qdxq':s_qdxq,'qdmode': s_qdmode,'todaysay':u'可樂社區是我家,我們大家都愛Ta...'}
      req = urllib2.Request( r'http://bbs.dakele.com/'+s_action, urllib.urlencode(loginparams), headers=self._getHeaders())
      response = urllib2.urlopen(req)
      self.operate = self.opener.open(req)
      thePage = response.read()
    else:
      logging.debug( u'今天已經簽到過...')
  def sign(self,url):
    logging.debug( 'start bbs sign : %s' % url)
    req = urllib2.Request(url,headers=self._getHeaders())
    response = urllib2.urlopen(req)
    self.operate = self.opener.open(req)
    thePage = response.read()
    self._say(thePage)
if __name__ == '__main__':
  userlogin = Dakele('username','password')
  bbs_loginurl = userlogin.login()
  userlogin.login_bbs(bbs_loginurl)
  userlogin.sign('http://bbs.dakele.com/dsu_paulsign-sign.html');

總結

以上所述實小編給大家介紹的Python實現某論壇自動簽到功能,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

津南区| 泊头市| 犍为县| 梧州市| 左权县| 上高县| 修水县| 柳州市| 珠海市| 西乌珠穆沁旗| 济南市| 正镶白旗| 大余县| 稻城县| 清原| 宝山区| 元阳县| 措美县| 专栏| 正蓝旗| 上犹县| 冀州市| 吉木萨尔县| 仪征市| 崇礼县| 安顺市| 竹溪县| 虎林市| 观塘区| 文水县| 寻甸| 淮滨县| 东光县| 广南县| 辽宁省| 安福县| 正宁县| 什邡市| 元朗区| 浑源县| 建瓯市|