array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } 111string(0) "" int(1) int(10) int(70) int(8640000) string(13) "likecs_art_db" array(1) { ["query"]=> array(1) { ["match_all"]=> object(stdClass)#28 (0) { } } } array(1) { ["createtime.keyword"]=> array(1) { ["order"]=> string(4) "desc" } } int(10) int(0) int(8640000) array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } request-html 登陆百度 - 爱码网
import asyncio

from requests_html import HTMLSession

url  = 'https://passport.baidu.com/v2/?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2F&sms=5'

session = HTMLSession( browser_args=[
        '--no-sand',
        '--disable-infobars'
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'
    ],headless=False)
res = session.request(url=url,method='GET')
script = """
                () => {
                    return {
                        width: document.documentElement.clientWidth,
                        height: document.documentElement.clientHeight,
                        deviceScaleFactor: window.devicePixelRatio,
                    }
                }
               """
try:
    res.html.render(keep_page = True)
    async def main():

        await res.html.page.waitFor(1000)
        await res.html.page.click(' [id = "TANGRAM__PSP_3__footerULoginBtn"]')
        await res.html.page.type(' []','maonanbei')
        await res.html.page.type(' []','goudouxi')
        await res.html.page.screenshot({'path': 'login.png'})

        await res.html.page.waitFor(100000000)
    asyncio.get_event_loop().run_until_complete(main())
except Exception as e:
    print(e)
finally:
    session.close()

相关文章: