SHARE
TWEET

loc_rubbish

abbeyok Nov 5th, 2018 182 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #-*- coding=utf-8 -*-
  2. """
  3. @title:hostloc加黑名单脚本
  4. @Author:Abbey
  5. @Description:通过本脚本,可在hostloc批量加黑名单。
  6. @使用说明:
  7. 1. 安装依赖:pip install requests
  8. 2. 修改脚本最后面的:username和passwd为你的hostloc用户名和密码
  9. 3. 修改需要加黑名单的列表:usernames
  10. 4. 运行:python loc_rubbish.py
  11. """
  12. import requests
  13. import re
  14. import sys
  15. import urllib3
  16. import time
  17.  
  18. urllib3.disable_warnings()
  19.  
  20. index='https://www.hostloc.com/'
  21. login_url='https://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1'
  22. add_rubbish_url='https://www.hostloc.com/home.php?mod=spacecp&ac=friend&op=blacklist&start='
  23. login_data={
  24.         'fastloginfield':'username'
  25.         ,'username':''
  26.         ,'cookietime':'2592000'
  27.         ,'password':''
  28.         ,'quickforward':'yes'
  29.         ,'handlekey':'ls'
  30.     }
  31. rubbish_data={
  32.     'username': '',
  33.     'blacklistsubmit_btn': 'true',
  34.     'blacklistsubmit': 'true',
  35.     'formhash': '',
  36. }
  37. headers={
  38.     'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
  39.     ,'Accept-Encoding':'gzip, deflate, sdch'
  40.     ,'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6'
  41.     ,'Host':'www.hostloc.com'
  42.     ,'Referer':'https://www.hostloc.com/forum.php'
  43.     ,'Upgrade-Insecure-Requests':'1'
  44.     ,'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
  45. }
  46.  
  47.  
  48. class HostLoc():
  49.     def __init__(self,username,passwd):
  50.         self.username=username
  51.         self.passwd=passwd
  52.         self.session=requests.Session()
  53.         self.session.headers=headers
  54.         login_data['username']=username
  55.         login_data['password']=passwd
  56.         login_data['formhash']=self.get_hidden_value(index,'formhash')
  57.         self.login()
  58.  
  59.     def login(self):
  60.         self.session.post(login_url,data=login_data,verify=False)
  61.  
  62.     def isLogin(self):
  63.         url='https://www.hostloc.com/home.php?mod=spacecp'
  64.         html=self.session.get(url).text
  65.         UserName=re.findall(self.username,html)
  66.         if len(UserName)==0:
  67.             return False
  68.         else:
  69.             return True
  70.  
  71.     def add_rubbish(self,username):
  72.         rubbish_data['username']=username
  73.         rubbish_data['formhash']=self.get_hidden_value('https://www.hostloc.com/home.php?mod=space&do=friend&view=blacklist','formhash')
  74.         r=self.session.post(add_rubbish_url,data=rubbish_data)
  75.         if len(re.findall('操作成功',r.text))>0:
  76.             print(u'{} 已加入黑名单'.format(username))
  77.  
  78.  
  79.     def get_hidden_value(self,url,keyname):
  80.         r=self.session.get(url)
  81.         cont=r.text
  82.         value=re.findall('<input type="hidden" name="{}" value="(.*?)" />'.format(keyname),cont)[0]
  83.         return value
  84.  
  85.  
  86.  
  87. if __name__=='__main__':
  88.     username='' #用户名
  89.     passwd='' #密码
  90.     #需要加黑名单的用户名放下面
  91.     usernames=["sunpma","dforel","gdtv","312633180","chxin","wusign","新网络","hostvps","abarler","yuqyu","大婊哥","肆无忌惮","蓝色骨头","大师兄","sunzetu","zhoutiancai","libie123456","tradekey1h","hellfires","laokof4n","liuxu","风铃","jshkk","dream7758521","march1993","hzaxcp386","sync","kkren","一灰","wayne630","msxcms","archlinux","tastypear","rko","hostxyz","iggfree","C51","letssAss","6vps.net","我在美国打飞机","251768938","shc","嗨起来","marcomarco","Wyane","itchin","v$v","douglasleft","skyflash","MikuProfessor","sarakuku","Jessynt","ultramancliub","billyfish152","seveneleven","vps999","root9000","黑街老祖","Nodejs"]
  92.     hostloc=HostLoc(username,passwd)
  93.     if hostloc.isLogin():
  94.         for username in usernames:
  95.             hostloc.add_rubbish(username)
  96.     else:
  97.         sys.exit(0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top