【发布时间】:2018-03-10 10:30:53
【问题描述】:
我想尝试pyppeteer 包,但感觉使用async 对我的小脚本来说有点矫枉过正。有没有办法同步运行异步代码?这是我尝试过的:
Python 3.6.3 (default, Oct 3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
[15:42:45]>>> import pyppeteer
[15:42:47]>>> browser = pyppeteer.launch()
[15:42:49]>>> pg = browser.newPage()
[15:42:52]>>> pg.goto('about:blank')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'coroutine' object has no attribute 'goto'
[15:42:55]>>> exit()
sys:1: RuntimeWarning: coroutine 'Browser.newPage' was never awaited
【问题讨论】:
标签: python-3.x asynchronous synchronous