当前位置: 首页 > news >正文

晚上偷偷看b站软件推荐网站seo平台

晚上偷偷看b站软件推荐,网站seo平台,汕头网站制作找哪家,wordpress admin 500近期因个人需要接触playwright,由于playwright新接触,想用jupyter进行API测试学习。刚开始使用sync_playwright,在playwright的Conda运行环境中,以console模式和单文件直接运行模式,都能正常运行。但是进入jupyter中后…

    近期因个人需要接触playwright,由于playwright新接触,想用jupyter进行API测试学习。刚开始使用sync_playwright,在playwright的Conda运行环境中,以console模式和单文件直接运行模式,都能正常运行。但是进入jupyter中后,sync_playwright就无法运行了。会出现如下提示:

Error: It looks like you are using Playwright Sync API inside the asyncio loop.
Please use the Async API instead.

在网上找到(如何在 Jupyter 笔记本中使用 Playwright 库而不是使用常规 .py 脚本(在 Windows 上) - python - SO中文参考 - www.soinside.com)这篇文章,才知道“Jupyter Notebook 使用 asyncio 事件循环,因此您应该使用 async api”。

于是将sync_playwright改成 async_playwright。然后又面临上述文章中的同样问题。

Not Implemented error

按照上述文章所说,更改jupyter核心运行库:

1、导航到 Python 目录中的 Lib/site-packages/ipykernel/kernelapp.py

2、将该文件中的一行代码注释掉

if sys.platform.startswith("win") and sys.version_info >= (3, 8):import asynciotry:from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicyexcept ImportError:pass# not affectedelse:if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:# WindowsProactorEventLoopPolicy is not compatible with tornado 6# fallback to the pre-3.8 default of Selector# 注释掉此行:asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())print(f'do not change to Selector Event Loop') #加入一行提示

则下述代码运行通过:

from playwright.async_api import async_playwrightplaywright = await async_playwright().start()
browser = await playwright.chromium.launch(headless = False,)c=await browser.new_context(viewport={'width':1024,'height':768})page = await c.new_page()await page.goto("http://image.baidu.com")await page.locator("#kw").fill("XXX...")await page.locator("#homeSearchForm > span.s_btn_wr > input").click()async with  page.expect_popup() as page1_info:await page.locator("#imgid > div > ul > li:nth-child(6)").click()
page1 = await page1_info.valueawait browser.close()
await playwright.stop()

此问题产生的原因,在这篇文章中有所描述:(Running Playwright in JupyterLab Notebook Problem - Not implemented Error - #2 by fomightez - JupyterLab - Jupyter Community Forum)

It appears that the problem is specific to Windows Platform and as identified in the original question as the use of SelectorEventLoopPolicy rather than ProactorEventloopPolicy in JupyterLabs is the source of the issue.

Since SelectorEventLoopPolicy does not support Pipes the Not implemented error occurs when Playwright first tries to open a pipe. 

...

#asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())

Comment out that line,

Not sure if this will have any adverse effects on other operations, but it does cause the original code to execute in JupyterLab.

似乎这个问题是特定于Windows平台的,并且在原始问题中确定为在JupyterLabs中使用SelectorEventLoopPolicy而不是ProactorEventloopPolicy是问题的根源。

由于SelectorEventLoopPolicy不支持管道,当playwright第一次尝试打开管道时,会出现not implemented错误。

#asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())

注释掉这行代码,

不确定这是否会对其他操作产生任何不利影响,但它确实会导致原始代码在JupyterLab中执行。

目前microsoft在github playwright的bug回复里,这个问题并没有得到解决。所以这只能是一时之选。

http://www.hrbkazy.com/news/42836.html

相关文章:

  • 云南省建设考试中心网站活动策划
  • 武汉网站建设电话多少钱比较正规的代运营
  • wordpress付费下载网站seo怎么做
  • 做家教用什么网站宁波网站seo哪家好
  • 马关县住房和城乡建设局网站手机建站平台
  • 东营网站建设dysem360关键词推广
  • 钓鱼网站模板制作做网站比较好的公司有哪些
  • 网站的跟目录优化设计三年级上册答案语文
  • 一个人做网站需要多久福州网站快速排名提升
  • 不用代码做网站的软件有了域名怎么建网站
  • vb.net网站开发百度公司全称
  • 做性事的视频网站网络推广是诈骗吗
  • 哪个网站可以做海报模板免费下载网站
  • 快速进入网站龙岩seo
  • 建筑工程东莞网站建设新型营销方式
  • 网站怎么做直通车制作网页app
  • 个人网站建设网站排名优化百度竞价排名黑幕
  • 海淀深圳网站建设公司价格自媒体是如何赚钱的
  • 网站图片的作用人民政府网站
  • 做网站怎么才会被百度收录疫情最新消息今天封城了
  • 阿里云做企业网站只要做好关键词优化
  • 南山网站设计费用代发广告平台
  • 高端网站定制建站高权重外链
  • 字体设计灵感网站张掖seo
  • wordpress域名改了北京seo排名方法
  • 如何做优秀的视频网站网站整站优化公司
  • 网站建设查看框架的源代码宁波seo关键词费用
  • 网站建设开发网站wrrgbdd关键词优化如何
  • 做网站推广每天加班哈尔滨网站制作软件
  • 微商产品做网站免费外链网站