-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#39 sync func calling async not problem
- Loading branch information
1 parent
131f43f
commit 3682926
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import asyncio | ||
from pyppeteer import launch | ||
|
||
async def browser_stuff(): | ||
browser = await launch() | ||
page = await browser.newPage() | ||
await page.goto('http://example.com') | ||
await page.screenshot({'path': 'example.png'}) | ||
await browser.close() | ||
|
||
def main(): | ||
loop = asyncio.get_event_loop() | ||
result = loop.run_until_complete(browser_stuff()) | ||
|
||
if __name__ == '__main__': | ||
main() |