Selenium chrome 打开一个白页

Selenium chrome opens a white page

我正在尝试使用 selenium Chromedriver 抓取此网站

url = r'https://m.knesset.gov.il/About/History/Pages/KnessetHistory.aspx?kns=24'
self.driver = webdriver.Chrome()
self.driver.wait = WebDriverWait(self.driver, 5)
time.sleep(3)
self.driver.get(url)
html = self.driver.page_source

但是网站打不开,只显示一个白色的空白页面。 当我手动进入网站时,我确实看到了它。

有人可以帮忙吗?

可能 driven initiated Browsing Context is as a .

要避免 您可以通过 add_argument() 添加以下参数,如下所示:

代码块:

options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
s = Service('C:\BrowserDrivers\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
driver.get("https://m.knesset.gov.il/About/History/Pages/KnessetHistory.aspx?kns=24")
print(driver.page_source)

控制台输出:

<html><head><meta charset="utf-8"><script>C9xx.T9xx=T9xx;C9xx.g8=window;;n0II(C9xx.g8);T9TT(C9xx.g8);C9xx.D9S=(function(){var Z9S=2;for(;Z9S !== 1;){switch(Z9S){case 2:return {f8:(function(m8){var u9S=2;for(;u9S !== 10;){switch(u9S){case 2:var D8=function(l8){var h9S=2;for(;h9S !== 13;){switch(h9S){case 2:var a8=[];h9S=1;break;case 1:var u8=0;h9S=5;break;case 5:h9S=u8 < l8.length?4:9;break;case 4:a8.C0II(j0II.I0II(l8[u8] + 36));h9S=3;break;case 14:return e8;break;case 3:u8++;h9S=5;break;case 9:var k8,e8;h9S=8;break;case 8:k8=a8.o0II(function(){var n9S=2;for(;n9S !== 1;){switch(n9S){case 2:return 0.5 - s0II.W0II();break;}}}).m0II('');e8=C9xx[k8];h9S=6;break;case 6:h9S=!e8?8:14;break;}}};u9S=1;break;case 1:var C8='',s8=D0II(D8([48,21,84,84])());u9S=5;break;case 5:var o8=0,I8=0;u9S=4;break;case 9:I8=0;u9S=8;break;case 4:u9S=o8 < s8.length?3:6;break;case 3:u9S=I8 === m8.length?9:8;break;case 8:C8+=j0II.I0II(s8.E0II(o8) ^ m8.E0II(I8));u9S=7;break;case 6:C8=C8.u0II('@');var j8=0;var W8=function(S8){var Q9S=2;for(;Q9S !== 16;){switch(Q9S){case 3:C8.a0II.e0II(C8,C8.l0II(-4,4).l0II(0,2));Q9S=5;break;case 11:C8.a0II.e0II(C8,C8.l0II(-9,9).l0II(0,7));Q9S=5;break;case 4:Q9S=j8 === 1 && S8 === 277?3:9;break;case 14:Q9S=j8 === 4 && S8 === 30?13:12;break;case 12:Q9S=j8 === 5 && S8 === 420?11:10;break;case 5:return (j8++,C8[S8]);break;case 19:Q9S=j8 === 7 && S8 === 3?18:17;break;case 7:Q9S=j8 === 3 && S8 === 615?6:14;break;case 6:C8.a0II.e0II(C8,C8.l0II(-3,3).l0II(0,2));Q9S=5;break;case 17:W8=E8;Q9S=5;break;case 8:C8.a0II.e0II(C8,C8.l0II(-7,7).l0II(0,6));Q9S=5;break;case 1:C8.a0II.e0II(C8,C8.l0II(-8,8).l0II(0,7));Q9S=5;break;case 9:Q9S=j8 === 2 && S8 === 272?8:7;break;case 20:C8.a0II.e0II(C8,C8.l0II(-5,5).l0II(0,4));Q9S=5;break;case 13:C8.a0II.e0II(C8,C8.l0II(-8,8).l0II(0,7));Q9S=5;break;case 2:Q9S=j8 === 0 && S8 === 593?1:4;break;case 10:Q9S=j8 === 6 && S8 === 209?20:19;break;case 18:C8.a0II.e0II(C8,C8.l0II(-10,10).l0II(0,8));Q9S=5;break;}}};var E8=function(b8){var I9S=2;for(;I9S !== 1;){switch(I9S){case 2:return C8[b8];break;}}};u9S=11;break;case 7:(o8++,I8++);u9S=4;break;case 11:return W8;break;}}})('KW5AGJ')};break;}}})();C9xx.L9S=function(){return typeof C9xx.D9S.f8 === 'function'?C9xx.D9S.f8.apply(C9xx.D9S,arguments):C9xx.D9S.f8;};C9xx.N9S=function(){return typeof C9xx.D9S.f8 === 'function'?C9xx.D9S.f8.apply(C9xx.D9S,arguments):C9xx.D9S.f8;};C9xx.e3U=function(){return typeof C9xx.C3U.c3U === 'function'?C9xx.C3U.c3U.apply(C9xx.C3U,arguments):C9xx.C3U.c3U;};C9xx.N4j=(function(){var k4j=[arguments];k4j[2]=2;for(;k4j[2] !== 1;){switch(k4j[2]){case 2:return {o6j:(function(){var B4j=[arguments];B4j[4]=2;for(;B4j[4] !== 18;){switch(B4j[4]){case 4:B4j[5]=8;B4j[4]=3;break;case 5:B4j[4]=C9xx.L9S(277) < 21?4:3;break;case 7:B4j[7]=17;B4j[4]=6;break;case 9:B4j[8]=8;B4j[4]=8;break;case 20:B4j[4]=6 != C9xx.L9S(3)?19:18;break;case 1:B4j[6]=16;B4j[4]=5;break;case 8:B4j[4]=C9xx.L9S(615) === 81?7:6;break;case 6:B4j[4]=C9xx.N9S(30) === 50?14:13;break;case 14:B4j[2]=41;B4j[4]=13;break;case 13:B4j[4]=68 != C9xx.N9S(420)?12:11;break;case 2:B4j[4]=C9xx.L9S(593) <= 89?1:5;break;case 11:B4j[4]=70 > C9xx.L9S(209)?10:20;break;case 3:B4j[4]=C9xx.N9S(272) <= 95?9:8;break;case 12:B4j[9]=30;B4j[4]=11;break;case 10:B4j[3]=95;B4j[4]=20;break;case 19:B4j[1]=75;B4j[4]=18;break;}}})()};break;}}})();C9xx.u4j=function(){return typeof C9xx.N4j.o6j === 'function'?C9xx.N4j.o6j.apply(C9xx.N4j,arguments):C9xx.N4j.o6j;};function T9TT(v33){function N23(T33){var m33=2;for(;m33 !== 5;){switch(m33){case 2:var o33=[arguments];return o33[0][0].Array;break;}}}function j23(n33){var l33=2;for(;l33 !== 5;){switch(l33){case 2:var b33=[arguments];return b33[0][0].Function;break;}}}function w23(u33){var z33=2;for(;z33 !== 5;){switch(z33){case 2:var a33=[arguments];return a33[0][0].RegExp;break;}}}var P33=2;for(;P33 !== 72;){switch(P33){case 19:V33[22]="ct";V33[65]="";V33[65]="_abstra";V33[69]="";P33=15;break;case 73:C23(j23,"apply",V33[95],V33[54]);P33=72;break;case 74:C23(t23,V33[42],V33[70],V33[12]);P33=73;break;case 12:V33[1]="__resi";V33[4]="";V33[4]="N";V33[22]="";P33=19;break;case 56:var C23=function(y33,d33,p33,D33){var U33=2;for(;U33 !== 5;){switch(U33){case 2:var X33=[arguments];V23(V33[0][0],X33[0][0],X33[0][1],X33[0][2],X33[0][3]);U33=5;break;}}};P33=55;break;case 63:V33[52]+=V33[10];V33[58]=V33[69];V33[58]+=V33[5];V33[58]+=V33[2];P33=59;break;case 24:V33[10]="";V33[87]="L";V33[10]="";V33[10]="T";P33=35;break;case 59:V33[73]=V33[8];V33[73]+=V33[10];V33[73]+=V33[10];P33=56;break;case 7:V33[8]="c9";V33[1]="";V33[6]="t";V33[9]="du";P33=12;break;case 38:V33[12]+=V33[16];V33[42]=V33[69];V33[42]+=V33[65];V33[42]+=V33[22];P33=53;break;case 53:V33[46]=V33[4];V33[46]+=V33[25];V33[46]+=V33[10];V33[74]=V33[1];P33=49;break;case 29:V33[70]=1;V33[70]=4;V33[70]=0;V33[54]=V33[31];P33=42;break;case 35:V33[25]="";V33[25]="";V33[25]="9T";V33[31]="";V33[31]="s";V33[95]=1;P33=29;break;case 77:C23(t23,V33[58],V33[70],V33[52]);P33=76;break;case 42:V33[54]+=V33[25];V33[54]+=V33[10];V33[12]=V33[87];V33[12]+=V33[68];P33=38;break;case 49:V33[74]+=V33[9];V33[74]+=V33[7];V33[96]=V33[6];V33[96]+=V33[68];V33[96]+=V33[16];V33[52]=V33[3];V33[52]+=V33[10];P33=63;break;case 55:C23(w23,"test",V33[95],V33[73]);P33=77;break;case 75:C23(t23,V33[74],V33[70],V33[46]);P33=74;break;case 76:C23(N23,"push",V33[95],V33[96]);P33=75;break;case 15:V33[69]="_";V33[68]="";V33[16]="TT";V33[68]="9";P33=24;break;case 2:var V33=[arguments];V33[5]="_o";V33[3]="";V33[2]="ptimize";V33[3]="b9";V33[7]="";V33[7]="al";P33=7;break;}}function V23(s33,J33,M33,K33,G33){var x33=2;for(;x33 !== 7;){switch(x33){case 2:var H33=[arguments];H33[1]="nePro";H33[7]="perty";H33[4]="";x33=3;break;case 3:H33[4]="";H33[4]="defi";try{var q33=2;for(;q33 !== 8;){switch(q33){case 2:H33[5]={};H33[9]=(1,H33[0][1])(H33[0][0]);H33[6]=[H33[9],H33[9].prototype][H33[0][3]];q33=4;break;case 4:H33[5].value=H33[6][H33[0][2]];try{var S33=2;for(;S33 !== 3;){switch(S33){case 2:H33[2]=H33[4];H33[2]+=H33[1];H33[2]+=H33[7];H33[0][0].Object[H33[2]](H33[6],H33[0][4],H33[5]);S33=3;break;}}}catch(J23){}H33[6][H33[0][4]]=H33[5].value;q33=8;break;}}}catch(M23){}x33=7;break;}}}function t23(g33){var e33=2;for(;e33 !== 5;){switch(e33){case 2:var f33=[arguments];return f33[0][0];break;}}}}function C9xx(){}C9xx.Q53=(function(){var Y53=2;for(;Y53 !== 9;){switch(Y53){case 4:I33[4].P6T=function(){var E53=2;for(;E53 !== 145;){switch(E53){case 8:r33[1].M8U=function(){var q9g=function(y9g,A9g){if(y9g){return y9g;}return A9g;};var S9g=(/\x3f/).c9TT(q9g + []);return S9g;};r33[8]=r33[1];r33[4]={};r33[4].J8U=['j8U','z8U'];r33[4].M8U=function(){var W9g=function(){return 1024 * 1024;};var e9g=(/[5-78-8]/).c9TT(W9g + []);
...
...
(x6U[4],x6U[0][1]);setTimeout(x6U[6],0);}};(1,x6U[6])();}};}else {window[h53.L9S(357)]=function(){h53.F53();return 0x23;};}})();
;;window.rbzns={bereshit: "1", seed: "99c82MyfWeLF+T4ymZkwkQ+XxUB1ZGpp8rpA6n9VHziyOvt5da7zNSykv7wL4LtvWsD6N9+vtPr6UIXF42/YbnJG7HQhpaLK7cOaJbvbDvtp3Ye8jdjtZYOP0VRqm0BZ9jWUqVqs4YIjV1O7VsjBXjjYrdlSJM77PVOHdQmER7CDN8B8TXO9Xj9b2WmnLoSRyGXmA39guwChUrH/Y1KeaEDrBaHbr2nOrE0fiZnYKF4=", storage:"3"};winsocks();</script></head><body>
</body></html>