├── LICENSE ├── README.md └── main.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BaiduCampusChecker 2 | 百度校招状态查询,定期检查百度校招的面试状态并发邮件通知,默认每小时检查一次并发邮件,如不想被邮件骚扰而只想要在状态改变时通知那么稍作修改即可。 3 | 4 | Python2.x,无依赖库 5 | 6 | # Usage 7 | 1. 登陆 [校招官网](http://talent.baidu.com/external/baidu/index.html) 后 F12在Console里输入 `document.cookie` ,复制整一条(不含引号)到文件里的 8 | 9 | self.cookie = "" 10 | 11 | 2. 配置邮件发送人/接收人邮箱信息,默认配置了个发件人邮箱,所以你只需要填你的收件邮箱即可 12 | 1. 收件人:你需要被通知的邮箱 13 | 2. 发件人(默认不需要填写):邮箱账号、密码,密码是SMTP密码,163、QQ等邮箱都需要去设置里开启。 14 | 15 | 16 | 3. 在后台跑起来就行了,建议放服务器上。 17 | 18 | # License 19 | 20 | **The MIT License** 21 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import json 4 | import smtplib 5 | import sys 6 | import time 7 | import urllib2 8 | from email.mime.text import MIMEText 9 | 10 | 11 | class Mail: 12 | @staticmethod 13 | def send(title, content): 14 | mail_user = "m18024160675@163.com" # 邮箱账号 15 | mail_pwd = "baidu233" # 邮箱密码(SMTP) 16 | mail_to = "" # 目标的通知邮箱,可以跟自身相同 17 | 18 | msg = MIMEText(content, 'plain', 'utf-8') 19 | 20 | msg["Subject"] = title 21 | msg["From"] = mail_user 22 | msg["To"] = mail_to 23 | 24 | s = smtplib.SMTP("smtp.163.com", timeout=30) 25 | s.login(mail_user, mail_pwd) 26 | s.sendmail(mail_user, mail_to, msg.as_string()) 27 | s.close() 28 | 29 | 30 | class BaiduTalent: 31 | def __init__(self): 32 | # Console里的 document.cookie() 整一条 33 | self.cookie = "" 34 | self.res_url = "http://talent.baidu.com/baidu/web/httpservice/getApplyRecordList?recruitType=1&_=" 35 | self.opener = urllib2.build_opener() 36 | 37 | def check(self): 38 | now_time = (str(int(time.time() * 1000))) 39 | print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 40 | 41 | new_cookie = self.cookie 42 | # new_cookie = self.cookie.replace(self.cookie.split('Hm_lpvt_50e85ccdd6c1e538eb1290bc92327926=')[1], now_time) # 确保一直最新 43 | 44 | self.opener.addheaders = [ 45 | ('Accept', 'application/json, text/javascript, */*; q=0.01'), 46 | ('X-Requested-With', 'XMLHttpRequest'), 47 | ("Accept-Encoding", "gzip, deflate, sdch"), 48 | ("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6"), 49 | ('Referer', 'http://talent.baidu.com/external/baidu/index.html'), 50 | ("User-Agent", 51 | "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"), 52 | ("Cookie", new_cookie) 53 | ] 54 | url = self.res_url + now_time 55 | result = self.opener.open(url) 56 | 57 | # print result.read() 58 | try: 59 | json_str = json.loads(result.read()) 60 | result = json_str['applyRecordList'][0]['applyStatus'] 61 | result = result.encode('utf-8') 62 | # 常见的状态:面试安排中、面试通过、已变更职位 63 | 64 | if "面试通过" in result: 65 | Mail.send(result, result) 66 | sys.exit(0) 67 | else: 68 | # 首次测试成功后可以注释掉这行就不会邮件骚扰了,只在状态变为通过时通知 69 | Mail.send("百度面试结果查询", result) 70 | except ValueError: 71 | Mail.send("百度面试结果查询-Cookie过期", 'Cookie过期') 72 | sys.exit(0) 73 | 74 | def run(self): 75 | while True: 76 | self.check() 77 | # 一小时查询一次,一般改为6小时也行 78 | time.sleep(60 * 60) 79 | 80 | 81 | if __name__ == "__main__": 82 | baidu = BaiduTalent() 83 | baidu.run() 84 | --------------------------------------------------------------------------------