Commit 8ea94abc by 张航玮

爬虫,结合网页分析

parent a2977a28
import asyncio
from pyppeteer import launch
import os
import random
def input_time_random():
return random.randint(100, 151)
async def main():
browser = await launch({
'headless': False, # 关闭无头模式
'devtools': False, # 打开 chromium 的 devtools
'executablePath': '/home/zhw/.local/share/pyppeteer/chrome',
'args': [
'--disable-extensions',
'--hide-scrollbars',
'--disable-bundled-ppapi-flash',
'--mute-audio',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-gpu',
],
'dumpio': True,
})
page = await browser.newPage()
await page.goto('http://192.168.1.1/')
#await page.type("#userName", "admin")
await page.type("#Pwd","admin", {'delay': input_time_random() - 50})
await page.click("#logIn_btn")
#page.mouse
#content = await page.content()
#cookies = await page.cookies()
await page.screenshot({'path': 'example.png'})
await page.waitFor(1)
# frame = page.frames
# print(frame)
# title = await frame[1].title()
# print(title)
# title_linklist=[]#Pwd#logIn_btn
#//*[@id="login_form"]//*[@id="logIn"]//*[@id="Pwd"]//*[@id="content"]#content
print("??????????????????")
# title_frame = await page.xpath('//*[@id="Pwd"]')
# print(title_frame)
await browser.close()
# title_elements = await title_frame[0].xpath('//*[@id="lo39"]')
# for item in title_elements:
# title_link = await (await item.getProperty('href')).jsonValue()
# title_linklist.append(title_link)
# await page.waitFor(1000)
# await page.screenshot({'path': 'example.png'})
# await browser.close()
# return {'cookies':cookies,'title_linklist':title_linklist}
# loop = asyncio.get_event_loop()
# task = asyncio.ensure_future(main())
# loop.run_until_complete(task)
# print(task.result())
asyncio.get_event_loop().run_until_complete(main())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment