├── Login ├── demo ├── encryptPwd.html ├── encryptPwd.js ├── getToken.html └── 美团.html ├── README.md ├── config.py ├── creat_token.py ├── demo.py ├── get_uuid.py ├── mongodb.py ├── parse.py └── view ├── db.pinglun.png.png ├── db_dianpu.png.png └── pacharm_pinglun.png.png /Login/demo: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import execjs 3 | from bs4 import BeautifulSoup 4 | import re 5 | from pyppeteer import launch 6 | from requests import Session 7 | 8 | class MeituanLogin: 9 | def __init__(self, Account, Password): 10 | self.Account = Account 11 | self.Password = Password 12 | self.session = Session() 13 | self.session.headers = { 14 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' 15 | } 16 | 17 | async def geth5Fingerprint(self): 18 | """ 19 | 获取h5指纹参数 20 | :return: 21 | """ 22 | browser = await launch({'args': ['--no-sandbox', '--disable-infobars'], }, userDataDir=r'D:\拉勾\userdata') 23 | page = await browser.newPage() 24 | await page.setJavaScriptEnabled(enabled=True) 25 | await page.setUserAgent( 26 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36') 27 | 28 | await page.goto('file:///D:/%E7%BE%8E%E5%9B%A2%E7%99%BB%E5%BD%95/%E7%BE%8E%E5%9B%A2.html') 29 | 30 | await asyncio.sleep(1) 31 | 32 | html = await page.content() 33 | h5Fingerprint = re.search('(.*?)
', html).group(1) 34 | print('h5指纹', h5Fingerprint) 35 | 36 | await asyncio.sleep(1) 37 | 38 | await page.goto('file:///D:/%E7%BE%8E%E5%9B%A2%E7%99%BB%E5%BD%95/encryptPwd.html') 39 | 40 | await asyncio.sleep(1) 41 | 42 | html = await page.content() 43 | encryptPwd = re.search('(.*?)', html).group(1) 44 | print('RSA加密密码', encryptPwd) 45 | 46 | await browser.close() 47 | return h5Fingerprint, encryptPwd 48 | 49 | def getCsrf(self): 50 | """ 51 | 获取认证Csrf参数 52 | :return: 53 | """ 54 | url = 'https://passport.meituan.com/account/unitivelogin?service=www&continue=https%3A%2F%2Fwww.meituan.com%2Faccount%2Fsettoken%3Fcontinue%3Dhttp%253A%252F%252Fcd.meituan.com%252F' 55 | 56 | r = self.session.get(url) 57 | soup = BeautifulSoup(r.text, 'lxml') 58 | csrf = soup.select('input[name="csrf"]')[0]['value'] 59 | print('认证参数', csrf) 60 | return csrf 61 | 62 | def encryptPwd(self): 63 | """ 64 | RSA加密密码 65 | :return: 66 | """ 67 | with open('encryptPwd.js', 'rb') as f: 68 | js = f.read().decode() 69 | 70 | ctx = execjs.compile(js) 71 | encryptPwd = ctx.call('encrypt', self.Password) 72 | print(encryptPwd) 73 | return encryptPwd 74 | 75 | def login(self): 76 | """ 77 | 登录 78 | :return: 79 | """ 80 | loginAPI = 'https://passport.meituan.com/account/unitivelogin?risk_partner=0&risk_platform=1&risk_app=-1&uuid=34ebfd8f4ae642cea831.1560995483.1.0.0&service=www&continue=https%3A%2F%2Fwww.meituan.com%2Faccount%2Fsettoken%3Fcontinue%3Dhttp%253A%252F%252Fcd.meituan.com%252F' 81 | loop = asyncio.get_event_loop() 82 | h5Fingerprint, encryptPwd = loop.run_until_complete(self.geth5Fingerprint()) 83 | csrf = self.getCsrf() 84 | # encryptPwd = self.encryptPwd() 85 | self.session.headers.update({ 86 | 'Referer': 'https://passport.meituan.com/account/unitivelogin?service=www&continue=https%3A%2F%2Fwww.meituan.com%2Faccount%2Fsettoken%3Fcontinue%3Dhttp%253A%252F%252Fcd.meituan.com%252F', 87 | 'X-CSRF-Token': csrf, 88 | 'X-Client': 'javascript', 89 | 'X-Requested-With': 'XMLHttpRequest', 90 | # 'Cookie': '__mta=150821513.1558451397565.1561008520641.1561008570304.18; _lxsdk_cuid=16aedc3059e43-0a001c8235bd0e-7a1b34-100200-16aedc3059fc8; iuuid=8928289956E0DEDC81258FF113EE55E612C6AE864E76B21E40DF562EBEE60133; _lxsdk=8928289956E0DEDC81258FF113EE55E612C6AE864E76B21E40DF562EBEE60133; webp=1; __utmz=74597006.1558767512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=74597006.426765488.1558767512.1558767512.1558953786.2; cityname=%E6%B7%B1%E5%9C%B3; i_extend=H__a100001__b2; ci=59; rvct=59%2C20%2C30%2C1%2C70%2C10%2C57%2C55%2C50; _hc.v=8aacd23f-d612-8bae-0082-9cea2ad85705.1558954306; uuid=34ebfd8f4ae642cea831.1560665036.1.0.0; mtcdn=K; lsu=; _lx_utm=utm_source%3Dso.com%26utm_medium%3Dorganic; _lxsdk_s=16b73539370-e55-13e-897%7C%7C17; SERV=www; LREF=aHR0cHM6Ly93d3cubWVpdHVhbi5jb20vYWNjb3VudC9zZXR0b2tlbj9jb250aW51ZT1odHRwJTNBJTJGJTJGY2QubWVpdHVhbi5jb20lMkY%3D; passport.sid=hnPB6A9LG_Djjn4azr3fdZ1Cb_8drWJt; passport.sid.sig=Wkwg3yhwzZxYDXr-dyw4EE0wxRU' 91 | }) 92 | data = { 93 | 'countrycode': '86', 94 | 'email': self.Account, 95 | 'password': encryptPwd, 96 | 'origin': 'account-login', 97 | 'csrf': csrf, 98 | 'requestCode': '', 99 | 'responseCode': '', 100 | 'h5Fingerprint': h5Fingerprint 101 | } 102 | 103 | r = self.session.post(loginAPI, data=data).json() 104 | print(r) 105 | 106 | if __name__ == '__main__': 107 | spider = MeituanLogin("手机号", "密码") 108 | spider.login() 109 | -------------------------------------------------------------------------------- /Login/美团.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 |
6 |