質問編集履歴
1
情報追加です
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,83 @@
|
|
25
25
|
|
26
26
|
|
27
27
|
なにか解決策などありませんでしょうか?
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
------------------
|
32
|
+
|
33
|
+
追加です。
|
34
|
+
|
35
|
+
環境は WIN-SERVER 2016 PHPは7.2 APACHE chromeは最新バージョンになります。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```ここに言語を入力
|
40
|
+
|
41
|
+
$browserFactory = new BrowserFactory();
|
42
|
+
|
43
|
+
$agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36";
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
// headless chromeの開始
|
48
|
+
|
49
|
+
$browser = $browserFactory->createBrowser([
|
50
|
+
|
51
|
+
'windowSize' => [1920, 1000],
|
52
|
+
|
53
|
+
'enableImages' => false,
|
54
|
+
|
55
|
+
'startupTimeout' => 360,
|
56
|
+
|
57
|
+
'keepAlive' => true,
|
58
|
+
|
59
|
+
]
|
60
|
+
|
61
|
+
);
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
$page = $browser->createPage();
|
68
|
+
|
69
|
+
$page->setUserAgent($agent);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
if(!empty($url_ary)){
|
76
|
+
|
77
|
+
foreach($url_ary as $key=>$url){
|
78
|
+
|
79
|
+
$navigation = $page->navigate($url);
|
80
|
+
|
81
|
+
$navigation->waitForNavigation(@HeadlessChromium\Page::NETWORK_IDLE);
|
82
|
+
|
83
|
+
$evaluation = $page->evaluate('document.documentElement.innerHTML');
|
84
|
+
|
85
|
+
$value = $evaluation->getReturnValue();
|
86
|
+
|
87
|
+
$source=str_replace(array("\r\n","\r","\n","\t"), '', $value);//改行削除
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
$source_ary[$key]=$source;
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
$browser->close();
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
$url_aryにURLの配列を入れてLOOPしています。
|