-
Notifications
You must be signed in to change notification settings - Fork 372
waitForNavigation doesn't work after clicking a link #58
Comments
Seems to have found a way to achieve, but I do not understand, do not know whether the correct, I hope to get your guidance, thank you
|
Your solution is correct. The problem of your first code is:
To avoid this situation, you need to start I will update document about |
sorry guys,i found the solution still not work in my case. any idea for this? async def main(): |
Since
So you need to use |
Updated document of Page.click() |
actually it's working for me at that line ,but still got the Navigation Timeout Exceeded: 30000 ms exceeded at line await asyncio.wait([page.click('#_searchButton'), page.waitForNavigation()]) |
Thank you for details. |
I understand the problem. Try the below code: import asyncio
from pyppeteer import launch
async def main() -> None:
browser = await launch({"headless": False, "args": ['--no-sandbox']})
page = await browser.newPage()
await page.goto('http://wsjs.saic.gov.cn')
await page.screenshot({'path': 'example.png'})
await asyncio.wait([page.waitForNavigation(), page.click('#txnS02')])
title = await page.title()
if title is None or title == "":
await page.reload({"waitUntil": "networkidle0"})
print(await page.title() + str(len(await browser.pages())))
await page.screenshot({'path': 'example1.png'})
await page.focus("input[name='request:sn']")
await page.type("input[name='request:sn']", "26716759", {"delay": 50})
await page.screenshot({'path': 'example2.png'})
result_page_future = asyncio.get_event_loop().create_future()
browser.once('targetcreated',
lambda target: result_page_future.set_result(target))
await page.click('#_searchButton'),
result_page = await (await result_page_future).page()
print(await result_page.title())
# await browser.close()
asyncio.get_event_loop().run_until_complete(main()) output is:
|
hi bro, but seems i'm not able to click the link inside the table. Means if this page is dynamic loading how can i access the content?Thanks import asyncio async def main() -> None:
asyncio.get_event_loop().run_until_complete(main()) |
You need to wait for page contents loaded.
|
Thank u bro!! |
Hi @miyakogi , could you give this post https://stackoverflow.com/questions/60763644/cant-go-on-clicking-on-the-next-page-button-while-scraping-certain-fields-from a shot in case there is any solution you would like to offer. The post that I created in there is about pyppeteer. Thanks. |
https://github.com/features
The page has been loaded but the navigation timed outpuppeteer solution
https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageclickselector-options
But how does python solve?
The text was updated successfully, but these errors were encountered: