问题
I encountered a strange problem when using cefsharp. The browser accessed Twitter and automatically scrolled to the bottom to load new posts. There should be many requests, but the Function GetResourceRequestHandler didn't capture any requests, and the function wasn't called at all. Using the same class to capture Pinterest, requests can be captured, including XHR.
The link to visit Twitter is https://twitter.com/HanamuraAsuka You can see many XHR requests in chrome's develop tool, such as https://api.twitter.com/2/timeline/media/
I tried many times and the function was called for only a few times.
Thanks.
chrome.RequestHandler = New TwitterRequestHandler
Public Class TwitterRequestHandler
Inherits RequestHandler
Protected Overrides Function GetResourceRequestHandler(chromiumWebBrowser As IWebBrowser, browser As IBrowser, frame As IFrame, request As IRequest, isNavigation As Boolean, isDownload As Boolean, requestInitiator As String, ByRef disableDefaultHandling As Boolean) As IResourceRequestHandler
If request.Url.Contains("/timeline/media/") Or request.Url.Contains("/timeline/profile/") Then
Return New TwitterResourceRequestHandler
End If
Return Nothing
End Function
End Class
来源:https://stackoverflow.com/questions/61577179/cefsharp-requesthandler-cant-catch-all-the-incoming-request