Replies: 3 comments
|
It absolutely does. Create a <?php
require __DIR__ . '/vendor/autoload.php';
use Playwright\Network\RouteInterface;
use Playwright\Playwright;
$context = Playwright::chromium(['headless' => true]);
$page = $context->newPage();
$m3u8Url = null;
$page->route('**/*.m3u8', function (RouteInterface $route) use (&$m3u8Url): void {
$m3u8Url = $route->request()->url();
$route->abort();
});
$html = <<<HTML
<!doctype html>
<html>
<body>
<script>
fetch('https://example.com/video/playlist.m3u8').catch(() => {});
</script>
</body>
</html>
HTML;
$page->goto('data:text/html,' . rawurlencode($html));
$context->close();
echo 'Captured m3u8 URL: ' . $m3u8Url;composer require playwright-php/playwright
vendor/bin/playwright-install --browsers
php demo.php |
0 replies
|
Thank you for the answer, after some changes it worked completely fine for my use case on my local machine. But when I added the app to my webserver the url is never extracted anymore it always fails. Does the package require some extra setup on Ubuntu? I've ran the install command again and I also ran the Playwright install-deps command. |
0 replies
|
CI tests pass on the Ubuntu runner.. without knowing if code are comparable. What exactly happens? Can you load the page? Is there anything in the console? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi first of all, thank you for this amazing project!
I have a question regarding request interception. I would like to intercept .m3u8 requests and access their URLs. For example, is something like the following javascript supported?
Is this approach supported in Playwright PHP? If so, what is the recommended way to implement this pattern so that I can capture the URL of .m3u8 files while aborting the request?
Thank you in advance for your guidance!
All reactions