質問編集履歴
2
て
test
CHANGED
File without changes
|
test
CHANGED
@@ -103,81 +103,3 @@
|
|
103
103
|
以下、略
|
104
104
|
|
105
105
|
```
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
#解決手段
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
結局、すごくダサいのですか for x in pq.items('td'):と for y in x.items('a'):の
|
114
|
-
|
115
|
-
二重ループで分岐処理することを書きました。(もっと縮められるとは思いますが・・・)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
```python
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
def kouhou_perse(url):
|
124
|
-
|
125
|
-
pq = PyQuery(url)
|
126
|
-
|
127
|
-
flg = False
|
128
|
-
|
129
|
-
txt = ""
|
130
|
-
|
131
|
-
stri = []
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
for ca in categories:
|
136
|
-
|
137
|
-
if flg == False:
|
138
|
-
|
139
|
-
c_start = ca
|
140
|
-
|
141
|
-
flg = True
|
142
|
-
|
143
|
-
continue
|
144
|
-
|
145
|
-
flg = False
|
146
|
-
|
147
|
-
for x in pq.items('td'):
|
148
|
-
|
149
|
-
for y in x.items('a'):
|
150
|
-
|
151
|
-
if y.attr('name')==c_start[0]:
|
152
|
-
|
153
|
-
flg = True
|
154
|
-
|
155
|
-
txt = ""
|
156
|
-
|
157
|
-
break
|
158
|
-
|
159
|
-
elif y.attr('name')==ca[0]:
|
160
|
-
|
161
|
-
flg = False
|
162
|
-
|
163
|
-
strj = [c_start[1],txt]
|
164
|
-
|
165
|
-
stri.append(strj)
|
166
|
-
|
167
|
-
txt = ""
|
168
|
-
|
169
|
-
c_start = ca
|
170
|
-
|
171
|
-
break
|
172
|
-
|
173
|
-
if flg == True:
|
174
|
-
|
175
|
-
txt = txt + x.text()
|
176
|
-
|
177
|
-
elif flg == False:
|
178
|
-
|
179
|
-
continue
|
180
|
-
|
181
|
-
return stri
|
182
|
-
|
183
|
-
```
|
1
自己解決しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -103,3 +103,81 @@
|
|
103
103
|
以下、略
|
104
104
|
|
105
105
|
```
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
#解決手段
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
結局、すごくダサいのですか for x in pq.items('td'):と for y in x.items('a'):の
|
114
|
+
|
115
|
+
二重ループで分岐処理することを書きました。(もっと縮められるとは思いますが・・・)
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
```python
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
def kouhou_perse(url):
|
124
|
+
|
125
|
+
pq = PyQuery(url)
|
126
|
+
|
127
|
+
flg = False
|
128
|
+
|
129
|
+
txt = ""
|
130
|
+
|
131
|
+
stri = []
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
for ca in categories:
|
136
|
+
|
137
|
+
if flg == False:
|
138
|
+
|
139
|
+
c_start = ca
|
140
|
+
|
141
|
+
flg = True
|
142
|
+
|
143
|
+
continue
|
144
|
+
|
145
|
+
flg = False
|
146
|
+
|
147
|
+
for x in pq.items('td'):
|
148
|
+
|
149
|
+
for y in x.items('a'):
|
150
|
+
|
151
|
+
if y.attr('name')==c_start[0]:
|
152
|
+
|
153
|
+
flg = True
|
154
|
+
|
155
|
+
txt = ""
|
156
|
+
|
157
|
+
break
|
158
|
+
|
159
|
+
elif y.attr('name')==ca[0]:
|
160
|
+
|
161
|
+
flg = False
|
162
|
+
|
163
|
+
strj = [c_start[1],txt]
|
164
|
+
|
165
|
+
stri.append(strj)
|
166
|
+
|
167
|
+
txt = ""
|
168
|
+
|
169
|
+
c_start = ca
|
170
|
+
|
171
|
+
break
|
172
|
+
|
173
|
+
if flg == True:
|
174
|
+
|
175
|
+
txt = txt + x.text()
|
176
|
+
|
177
|
+
elif flg == False:
|
178
|
+
|
179
|
+
continue
|
180
|
+
|
181
|
+
return stri
|
182
|
+
|
183
|
+
```
|