使用Selenium访问旺富网股票页面图表显示undefined的反爬绕过求助
问题:绕过网站的Selenium访问限制以正常加载图表
- 手动访问某股票资讯页面时,图表可完全正常加载;但通过Selenium访问该页面时,图表无法显示且提示‘undefined’(动态图表区域显示undefined)。
- 已确认该网站存在针对Selenium的访问限制,现寻求绕过该限制的解决方案。
当前使用的VBA代码
Dim Mychorme As Selenium.ChromeDriver Sub Take_ScreenShot_Entirepage_Cropped() Dim wdh As Integer Dim hght As Integer Dim topOffset As Integer Dim bottomOffset As Integer Dim filePath As String topOffset = 500 ' bottomOffset = 500 ' filePath = ThisWorkbook.Path Set Mychorme = New Selenium.ChromeDriver With Mychorme .Timeouts.ImplicitWait = 5000 .Start .Get "https://wantrich.chinatimes.com/tw-market/listed/stock/3167" wdh = .ExecuteScript("return document.body.scrollWidth") hght = .ExecuteScript("return document.body.scrollHeight") .Window.SetSize wdh, hght - topOffset - bottomOffset .ExecuteScript "window.scrollTo(0, " & topOffset & ");" Application.Wait (Now + TimeValue("0:00:03")) .TakeScreenshot.SaveAs filePath & "\screenCapture_Entirepage_Cropped.png" .Quit End With End Sub
内容的提问来源于stack exchange,提问作者Hsuan hsien Lin
相关产品推荐
相关产品推荐

