Beispiel #1
0
# import cgi
import json
import user

# form = cgi.FieldStorage()
# TODO: get anything needed like: info = form.getvalue('info')

name = user.getName()
username = user.getUsername()
data = {'name': name, 'username': username}

print('Content-Type: text/json')
print('')
print(json.dumps(data))
Beispiel #2
0
def main():
  import user
  import terminal
  import growl
  import errors
  import strings
  
  #initialize vars
  isTerminal = True
  isConfigFile = True
  isDebug = False
  isGUI = False
  useGrowl = True
  lang = 'EN'
  delay = 10
  timeoutlimit = 5
  timeout = 0
  redditUsers = []
  notificationReceivers = []
  gui = None
  
  """implement code to support multiple languages
    if lang == 'EN':
  """

    
    
  
  """
  Read command line argruments
  -----------------------------
  -c = use configuration file conf.ini for username,password,delahy
  -t = display notification in termial
  -g = display notification in Growl
  -i = use GUI interface for user configuration
  -d = use debug mode, print debug statments to terminal
  """
  for arg in sys.argv:
    if arg == '-t':
      isTerminal = True
    elif arg == '-c':
      isConfigFile = True
    elif arg == '-d':
      isDebug = True
    elif arg == '-i':
      isGUI = True
    elif arg == '-g':
      useGrowl = True
      
  if isDebug: print """Running with:
  isDebug = %s
  isTerm = %s
  isConfigFile %s \n""" % (isDebug,isTerminal,isConfigFile)
  
  if isTerminal: 
    print strings.welcome
    notificationReceivers.append(terminal.Terminal())
    if isDebug: print "Initialized terminal as Notification Receiver"
  
  if isGUI:
    #initialize Tkinter gui for User Configuration
    pass
  if useGrowl:
    notificationReceivers.append(growl.Growl())
    
  if isConfigFile:
    import conf
    #add code to check these values
    delay = conf.delay 
    timeoutlimit = conf.timeoutlimit
    if isDebug: 
      print "Delay set to %i by conf.py" % delay
      print "Timeout limit set to %i by conf.py" % timeoutlimit
    
    for x in conf.users:
      #construct new user and append to redditUsers
      if isDebug: print "Trying to login: %s" % x['username']
      try:
        redditUsers.append(user.User(x['username'],x['password']))
      except errors.GRorangeCantAuthenticate as e:
        print strings.cantLogin % (x['username'],str(e))
        if isDebug: print "Password: %s" % x['password']
        continue
    
  if isDebug: 
    for user in redditUsers:
      print "Added user account for: %s" % user.getUsername()
  
  #main loop for message checking
  if not len(redditUsers):
    print strings.nousers
    sys.exit()
  while True:
    for user in redditUsers:
      if isDebug: print "Checking messages for %s" % user.getUsername()
      try:
        num = user.hasNewMsgs()
      except errors.GRorangeCantConnectToReddit as e:
        timeout += 1
        if timeout == timeoutlimit:
          print strings.timeoutclose
          sys.exit()
        else:
          print strings.timeoutretry % (timeoutlimit-timeout)
      else:
        timeout = 0
        
      if num:
        for notifier in notificationReceivers:
          notifier.notify(user.getUsername(),num)
          if isDebug: print "Found new messages!"
      else:
        if isDebug: print "No new messages."
    if isDebug: print "Waiting %i seconds." % delay
    time.sleep(delay) #wait for delay seconds
Beispiel #3
0
'''
import user,uuwise
import zh
from collections import deque

#1.获取可用代理,返回deque
# pf = proxyFactory.ProxyFactory()
# pf.Run()
# proxyPairs = pf.proxyPairs
proxyList = [{'http': 'http://101.200.202.168:80'}, {'http': 'http://222.88.182.52:8000'}, {'http': 'http://101.26.38.162:83'}, {'http': 'http://222.89.107.137:8000'}, {'http': 'http://222.89.178.65:8000'}, {'http': 'http://123.54.0.18:8000'}, {'http': 'http://123.54.6.39:8000'}, {'http': 'http://58.252.2.5:8000'}, {'http': 'http://123.54.6.38:8000'}, {'http': 'http://110.52.232.45:8000'}, {'http': 'http://101.26.38.162:82'}, {'http': 'http://101.26.38.162:80'}, {'http': 'http://101.81.50.255:8118'}, {'http': 'http://119.188.115.27:80'}, {'http': 'http://117.169.66.230:80'}, {'http': 'http://112.25.185.171:8000'}, {'http': 'http://58.83.174.114:80'}, {'http': 'http://119.188.115.27:8088'}, {'http': 'http://223.68.133.236:8000'}, {'http': 'http://123.163.25.21:8000'}, {'http': 'http://183.247.158.197:80'}, {'http': 'http://123.163.52.24:8000'}, {'http': 'http://27.115.75.114:8080'}, {'http': 'http://58.20.232.245:8000'}, {'http': 'http://111.2.196.130:80'}, {'http': 'http://171.35.242.180:80'}, {'http': 'http://113.195.207.249:8000'}, {'http': 'http://222.89.238.61:80'}, {'http': 'http://58.252.8.25:8000'}, {'http': 'http://58.20.128.123:80'}, {'http': 'http://58.22.191.242:80'}, {'http': 'http://112.25.234.188:8000'}, {'http': 'http://221.213.51.82:8090'}, {'http': 'http://117.177.250.153:85'}, {'http': 'http://220.249.151.60:80'}, {'http': 'http://218.104.236.234:80'}, {'http': 'http://117.177.250.149:83'}, {'http': 'http://171.35.242.180:8000'}, {'http': 'http://117.177.250.154:84'}, {'http': 'http://110.52.232.75:8000'}, {'http': 'http://58.22.191.243:80'}, {'http': 'http://58.16.145.184:8000'}, {'http': 'http://117.177.250.151:86'}, {'http': 'http://111.1.89.254:80'}, {'http': 'http://117.177.250.149:84'}, {'http': 'http://120.194.85.49:8000'}]
proxyPairs = deque()
for i in proxyList:
    proxyPairs.append(i)
#2.获取user和pwd
user = user.user()
user.getUsername()
account = user.account
pwd = user.pwd
#uuwise登录
u = uuwise.uuwise()    #创建验证码识别类
u.uu_login()    #uuwise账号登录,返回UU
#获取被发送私信用户,返回list
# account_default = '*****@*****.**'
# pwd_default = 'mix5300'
# proxy_default = {'http' : '222.88.182.52:8000'}
# default_zhihu = zh.ZhiHu(email=account_default, pwd=pwd_default, proxy=proxy_default,uuwise=u)
# follower_urls = default_zhihu.get_allfollers("https://www.zhihu.com/people/zhou-you-rong/followers")
follower_urls = ['https://www.zhihu.com/people/liu-chao-71-34', 'https://www.zhihu.com/people/a-tong-mu-50-66', 'https://www.zhihu.com/people/dong-shi-mei-32', 'https://www.zhihu.com/people/SHUAIBUHAUAI', 'https://www.zhihu.com/people/juan-xing-40', 'https://www.zhihu.com/people/wang-wang-4-97', 'https://www.zhihu.com/people/song-ling-shi-liao-31', 'https://www.zhihu.com/people/yi-zhong-zhi-57-89-65']
#五人一组,登录知乎,获取验证码
message_count = 0
proxy = None