質問編集履歴
2
全く異なる質問に変更しました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
BS4で<td>タグを抜き取った際に順番が入れ替わってしまう
|
test
CHANGED
@@ -1,133 +1,131 @@
|
|
1
|
-
|
1
|
+
BeautifulSoupでtdタグでとクラスで絞って抽出したのですが、なぜかHPの表示と順番がずれてしまいます。
|
2
2
|
|
3
|
-
communicationで色々と検索してみたのですが、ヒントとなるような頁が出てきませんでした。
|
4
|
-
|
5
|
-
|
3
|
+
どなたかわかるかたがいたらご教示ください。
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
以下のURLを参考に進め、migrateのところで行き詰まりました。
|
12
|
-
|
13
|
-
https://qiita.com/k_ken/items/4a4cc9914feebf60bbc0
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
4
|
|
19
5
|
|
20
6
|
|
21
7
|
```python
|
22
8
|
|
23
|
-
|
9
|
+
url = "https://dt.kabumap.com/servlets/dt/Action?SRC=change/base"
|
24
10
|
|
25
|
-
|
11
|
+
html = requests.get(url)
|
26
12
|
|
27
|
-
|
13
|
+
html.encoding = html.apparent_encoding
|
28
14
|
|
29
|
-
|
15
|
+
soup = BeautifulSoup(html.text, 'html.parser')
|
16
|
+
|
17
|
+
table = soup.find_all("td", attrs={"class": "onlyPc fontS"})
|
30
18
|
|
31
19
|
|
32
|
-
|
33
|
-
During handling of the above exception, another exception occurred:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Traceback (most recent call last):
|
38
|
-
|
39
|
-
File "manage.py", line 21, in <module>
|
40
|
-
|
41
|
-
main()
|
42
|
-
|
43
|
-
File "manage.py", line 17, in main
|
44
|
-
|
45
|
-
execute_from_command_line(sys.argv)
|
46
|
-
|
47
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
|
48
|
-
|
49
|
-
utility.execute()
|
50
|
-
|
51
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
|
52
|
-
|
53
|
-
django.setup()
|
54
|
-
|
55
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
|
56
|
-
|
57
|
-
apps.populate(settings.INSTALLED_APPS)
|
58
|
-
|
59
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
|
60
|
-
|
61
|
-
app_config.ready()
|
62
|
-
|
63
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/config.py", line 27, in ready
|
64
|
-
|
65
|
-
self.password_reset_form = get_class('customer.forms', 'PasswordResetForm')
|
66
|
-
|
67
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 42, in get_class
|
68
|
-
|
69
|
-
return get_classes(module_label, [classname], module_prefix)[0]
|
70
|
-
|
71
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 52, in get_classes
|
72
|
-
|
73
|
-
return class_loader(module_label, classnames, module_prefix)
|
74
|
-
|
75
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 110, in default_class_loader
|
76
|
-
|
77
|
-
oscar_module = _import_module(oscar_module_label, classnames)
|
78
|
-
|
79
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 144, in _import_module
|
80
|
-
|
81
|
-
return __import__(module_label, fromlist=classnames)
|
82
|
-
|
83
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/apps/customer/forms.py", line 14, in <module>
|
84
|
-
|
85
|
-
from oscar.apps.customer.utils import get_password_reset_url, normalise_email
|
86
|
-
|
87
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/apps/customer/utils.py", line 8, in <module>
|
88
|
-
|
89
|
-
Dispatcher = get_class('communication.utils', 'Dispatcher')
|
90
|
-
|
91
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 42, in get_class
|
92
|
-
|
93
|
-
return get_classes(module_label, [classname], module_prefix)[0]
|
94
|
-
|
95
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 52, in get_classes
|
96
|
-
|
97
|
-
return class_loader(module_label, classnames, module_prefix)
|
98
|
-
|
99
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 110, in default_class_loader
|
100
|
-
|
101
|
-
oscar_module = _import_module(oscar_module_label, classnames)
|
102
|
-
|
103
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 144, in _import_module
|
104
|
-
|
105
|
-
return __import__(module_label, fromlist=classnames)
|
106
|
-
|
107
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/apps/communication/utils.py", line 9, in <module>
|
108
|
-
|
109
|
-
CommunicationEventType = get_model('communication', 'CommunicationEventType')
|
110
|
-
|
111
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/oscar/core/loading.py", line 248, in get_model
|
112
|
-
|
113
|
-
return apps.get_model(app_label, model_name)
|
114
|
-
|
115
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/apps/registry.py", line 205, in get_model
|
116
|
-
|
117
|
-
app_config = self.get_app_config(app_label)
|
118
|
-
|
119
|
-
File "/Users/you_1_low/anaconda3/envs/py38/lib/python3.8/site-packages/django/apps/registry.py", line 162, in get_app_config
|
120
|
-
|
121
|
-
raise LookupError(message)
|
122
|
-
|
123
|
-
LookupError: No installed app with label 'communication'.
|
124
20
|
|
125
21
|
```
|
126
22
|
|
127
23
|
|
128
24
|
|
25
|
+
下から2番目と3番目が逆になってしまう。
|
26
|
+
|
27
|
+
```結果
|
28
|
+
|
29
|
+
[<td class="onlyPc fontS"><span>JQS</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
30
|
+
|
31
|
+
<td class="onlyPc fontS"><span>JQS</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
32
|
+
|
33
|
+
<td class="onlyPc fontS"><span>東マ</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
34
|
+
|
35
|
+
<td class="onlyPc fontS"><span>東マ</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
36
|
+
|
37
|
+
<td class="onlyPc fontS"><span>東2</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
38
|
+
|
39
|
+
<td class="onlyPc fontS"><span>JQS</span></td>, <td class="onlyPc fontS"><span>貸借</span></td>,
|
40
|
+
|
41
|
+
<td class="onlyPc fontS"><span>東マ</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
42
|
+
|
43
|
+
<td class="onlyPc fontS"><span>東2</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
44
|
+
|
45
|
+
<td class="onlyPc fontS"><span>東1</span></td>, <td class="onlyPc fontS"><span>貸借</span></td>,
|
46
|
+
|
47
|
+
<td class="onlyPc fontS"><span>東1</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
48
|
+
|
49
|
+
<td class="onlyPc fontS"><span>JQG</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
50
|
+
|
51
|
+
<td class="onlyPc fontS"><span>東1</span></td>, <td class="onlyPc fontS"><span>貸借</span></td>,
|
52
|
+
|
53
|
+
<td class="onlyPc fontS"><span>札証</span></td>, <td class="onlyPc fontS"><span></span></td>, ←ここの札証と上の東1の順番が逆になっている。
|
54
|
+
|
55
|
+
<td class="onlyPc fontS"><span>東2</span></td>, <td class="onlyPc fontS"><span>制度</span></td>,
|
129
56
|
|
130
57
|
|
131
|
-
なお、チュートリアル上、setting.pyのTEMPLATESの中の以下の部分が見つからなかったため、コメントアウトしました。もしかしたらこれが原因かもしれません・・・
|
132
58
|
|
133
|
-
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```HTML
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<td class="figure">12</td>
|
68
|
+
|
69
|
+
<td class="onlyTbPc"><a href="Action?SRC=basic/base&codetext=2928" target="_blank">2928</a></td>
|
70
|
+
|
71
|
+
<td><div class="chartWrap fontS"><a onmouseover="javascript:showChart('2928');" onmouseout="javascript:hideChart('2928');"href="Action?SRC=basic/base&codetext=2928">RIZAPグループ</a><div id="chart2928" class="popChart"><img src="cgi-bin/picoLight/pl.pl?2928,210,100,5c1d3a9b7425f22e83d506858d85be0720743850,156.0" width="210" height="100" /></div></div></td>
|
72
|
+
|
73
|
+
<td class="onlyPc fontS"><span>札証</span></td>
|
74
|
+
|
75
|
+
<td class="onlyPc fontS"><span></span></td>
|
76
|
+
|
77
|
+
<td class="onlySp">09/18<br>15:30</td>
|
78
|
+
|
79
|
+
<td class="onlyTbPc">09/18</td>
|
80
|
+
|
81
|
+
<td class="onlyTbPc">15:30</td>
|
82
|
+
|
83
|
+
<td class="figure onlyTbPc">168.0</td>
|
84
|
+
|
85
|
+
<td class="figure up onlyTbPc">+12.0</td>
|
86
|
+
|
87
|
+
<td class="figure up onlyTbPc">+7.69</td>
|
88
|
+
|
89
|
+
<td class="figure onlyPc">823,900</td>
|
90
|
+
|
91
|
+
<td class="emp figure up">+8.39</td>
|
92
|
+
|
93
|
+
<td class="figure onlyPc">85</td>
|
94
|
+
|
95
|
+
<td class="figure onlyPc">93</td>
|
96
|
+
|
97
|
+
<td class="figure onlyPc">56.42</td></tr>
|
98
|
+
|
99
|
+
<tr><td class="figure">13</td>
|
100
|
+
|
101
|
+
<td class="onlyTbPc"><a href="Action?SRC=basic/base&codetext=7014" target="_blank">7014</a></td>
|
102
|
+
|
103
|
+
<td><div class="chartWrap fontS"><a onmouseover="javascript:showChart('7014');" onmouseout="javascript:hideChart('7014');"href="Action?SRC=basic/base&codetext=7014">名村造船所</a><div id="chart7014" class="popChart"><img src="cgi-bin/picoLight/pl.pl?7014,210,100,5c1d3a9b7425f22e83d506858d85be0720743850,156.0" width="210" height="100" /></div></div></td>
|
104
|
+
|
105
|
+
<td class="onlyPc fontS"><span>東1</span></td>
|
106
|
+
|
107
|
+
<td class="onlyPc fontS"><span>貸借</span></td>
|
108
|
+
|
109
|
+
<td class="onlySp">09/18<br>15:00</td>
|
110
|
+
|
111
|
+
<td class="onlyTbPc">09/18</td><td class="onlyTbPc">15:00</td>
|
112
|
+
|
113
|
+
<td class="figure onlyTbPc">168.0</td>
|
114
|
+
|
115
|
+
<td class="figure up onlyTbPc">+12.0</td>
|
116
|
+
|
117
|
+
<td class="figure up onlyTbPc">+7.69</td>
|
118
|
+
|
119
|
+
<td class="figure onlyPc">1,118,400</td>
|
120
|
+
|
121
|
+
<td class="emp figure up">+8.39</td>
|
122
|
+
|
123
|
+
<td class="figure onlyPc">50</td>
|
124
|
+
|
125
|
+
<td class="figure onlyPc">12</td>
|
126
|
+
|
127
|
+
<td class="figure onlyPc">45.63</td></tr>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
```
|
1
手を入れた箇所を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
以下のURLを参考に進め、migrateのところで行き詰まりました。
|
12
12
|
|
13
13
|
https://qiita.com/k_ken/items/4a4cc9914feebf60bbc0
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
14
18
|
|
15
19
|
|
16
20
|
|
@@ -119,3 +123,11 @@
|
|
119
123
|
LookupError: No installed app with label 'communication'.
|
120
124
|
|
121
125
|
```
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
なお、チュートリアル上、setting.pyのTEMPLATESの中の以下の部分が見つからなかったため、コメントアウトしました。もしかしたらこれが原因かもしれません・・・
|
132
|
+
|
133
|
+
'oscar.apps.customer.notifications.context_processors.notifications',
|