Page 1 of 2
Get all links
Posted: Mon Mar 06, 2023 9:03 pm
by Vaytl
Hi, Salvadordf.
Can you please tell me how can I get a list of all the loaded links on a web page?
Re: Get all links
Posted: Tue Mar 07, 2023 8:44 am
by salvadordf
Hi,
Use the code in the
MiniBrowser demo.
Modify the
TMiniBrowserFrm.WVBrowser1AfterCreated procedure to filter all resources instead of images and media :
Code: Select all
WVBrowser1.AddWebResourceRequestedFilter('*', COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
Then modify
TMiniBrowserFrm.WVBrowser1WebResourceRequested and read the URL from the request :
Code: Select all
var
TempRequest : TCoreWebView2WebResourceRequestRef;
begin
[...]
TempRequest := TCoreWebView2WebResourceRequestRef.Create(TempArgs.Request);
My_URI_copy := TempRequest.URI;
TempRequest.Free;
end;
Re: Get all links
Posted: Tue Mar 07, 2023 1:34 pm
by Vaytl
Thank you very much, it works great.
Re: Get all links
Posted: Mon Mar 27, 2023 7:49 am
by nanaksr
This not get Links + Preflight
is there a solution?
Re: Get all links
Posted: Mon Mar 27, 2023 7:59 am
by salvadordf
nanaksr wrote: Mon Mar 27, 2023 7:49 am
This not get Links + Preflight
is there a solution?
Try using the DevTools methods.
Enable the network tracking with "
Network.enable" and events like "
Network.requestWillBeSent" will be delivered to the client.
Run the
SubscribeToDevToolsProtocolEventBrowser demo to see how to use the DevTools methods and read this for more information :
https://chromedevtools.github.io/devtools-protocol/1-3/Network/
Re: Get all links
Posted: Mon Mar 27, 2023 8:19 am
by nanaksr
Please give me example, I am still confused.
Re: Get all links
Posted: Mon Mar 27, 2023 10:07 am
by nanaksr
nanaksr wrote: Mon Mar 27, 2023 8:19 am
Please give me example, I am still confused.
I have successfully tried it.
The next problem, the link still can not be displayed. From a web link structure loaded by an Iframe from a third party.
Source : https://www.xm.com/research/economicCalendar
I want to get link : https://api.tradingcentral.com/permissions/v3/self?token=xxxxxxxxxxxxxxxxxxxxxxxxxx
I just need "token"

Re: Get all links
Posted: Tue Mar 28, 2023 12:53 pm
by salvadordf
The two methods commented in this thread are he only way I know to get the a list of loaded resources in WebView2.
I'm sorry but I can't help you.
Re: Get all links
Posted: Tue Mar 28, 2023 2:50 pm
by nanaksr
Thank you for the help.
Again

, how do set active frames in DevTools? like the image below.

Re: Get all links
Posted: Tue Mar 28, 2023 5:55 pm
by salvadordf
The WebView2 API doesn't have any method or property to set the active frames in the DevTools.
Perhaps there's a DevTools method to do that but I've never done that :
https://chromedevtools.github.io/devtools-protocol/1-3/