質問編集履歴

2

コード内容の詳細を記載した

2019/02/21 17:09

投稿

SZR0601
SZR0601

スコア22

test CHANGED
File without changes
test CHANGED
@@ -6,11 +6,71 @@
6
6
 
7
7
  ```python3
8
8
 
9
- for ******
9
+ search = []
10
10
 
11
- if (タイムアウトエラーが発生したことを示す):
12
11
 
12
+
13
+ result = []
14
+
15
+
16
+
17
+ with open('IPlist.txt', encoding='utf-8') as f:
18
+
19
+
20
+
21
+ for rows in f:
22
+
23
+ row = rows.rstrip('\n\n')
24
+
25
+ search.append(row)
26
+
27
+
28
+
29
+ for ip in search:
30
+
31
+ #seleniumでブラックリスト検索画面に移行
32
+
33
+ driver.get('https://www.aguse.jp/')
34
+
35
+ sleep(1)
36
+
13
- 任意の処理
37
+ #検索欄を選択
38
+
39
+ id=driver.find_element_by_id('url')
40
+
41
+ #searchからipアドレスを一つずつ検索欄に入力する
42
+
43
+ id.send_keys(ip)
44
+
45
+ sleep(1)
46
+
47
+
48
+
49
+ #検索開始ボタンを押下する
50
+
51
+ driver.find_element_by_class_name('btn1').click()
52
+
53
+ element = WebDriverWait(driver, 60).until(
54
+
55
+ EC.presence_of_element_located((By.CLASS_NAME, "section-body"))
56
+
57
+ )
58
+
59
+
60
+
61
+ sleep(10)
62
+
63
+
64
+
65
+ source = driver.page_source
66
+
67
+ soup = BeautifulSoup(source, "html.parser")
68
+
69
+
70
+
71
+ if タイムアウトエラーが発生したことを示す:
72
+
73
+ result.append('timeout')
14
74
 
15
75
  continue
16
76
 

1

タイムアウト時のエラー内容を追記

2019/02/21 17:09

投稿

SZR0601
SZR0601

スコア22

test CHANGED
@@ -1 +1 @@
1
- python3でのスクレイピングのタイムアウトエラー表現につ
1
+ python3でのスクレイピングのタイムアウトエラー表現方法を教えてくださ
test CHANGED
@@ -24,4 +24,22 @@
24
24
 
25
25
 
26
26
 
27
+ タイムアウト時のエラー内容は以下となります。
28
+
29
+ ```
30
+
31
+ selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
32
+
33
+ Message: unexpected alert open: {Alert text : タイムアウトしました}
34
+
35
+ (Session info: chrome=72.0.3626.109)
36
+
37
+ (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5
38
+
39
+ ab),platform=Windows NT 6.3.9600 x86_64)
40
+
41
+ ```
42
+
43
+
44
+
27
45
  よろしくお願いいたします。