質問編集履歴
3
9/26再更新 コード最下部
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,7 +82,9 @@
|
|
82
82
|
|
83
83
|
```**ここからアドバイス頂いた後トライしているもの
|
84
84
|
|
85
|
+
|
86
|
+
|
85
|
-
price = ''
|
87
|
+
price = ''
|
86
88
|
|
87
89
|
|
88
90
|
|
@@ -96,7 +98,7 @@
|
|
96
98
|
|
97
99
|
|
98
100
|
|
99
|
-
url = 'http://'
|
101
|
+
url = 'http://kakaku.com/kuruma/used/spec/Maker=1/Model=31773'
|
100
102
|
|
101
103
|
html = requests.get(url)
|
102
104
|
|
@@ -118,7 +120,9 @@
|
|
118
120
|
|
119
121
|
a_list = []
|
120
122
|
|
123
|
+
for j in b:
|
124
|
+
|
121
|
-
a_list.append(
|
125
|
+
a_list.append(j)
|
122
126
|
|
123
127
|
|
124
128
|
|
@@ -128,6 +132,6 @@
|
|
128
132
|
|
129
133
|
writer.writerow(a_list)
|
130
134
|
|
131
|
-
|
135
|
+
```
|
132
136
|
|
133
137
|
```
|
2
アドバイス後頂いた後にトライしたコードを再更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,11 +78,11 @@
|
|
78
78
|
|
79
79
|
|
80
80
|
|
81
|
-
|
81
|
+
**
|
82
82
|
|
83
83
|
```**ここからアドバイス頂いた後トライしているもの
|
84
84
|
|
85
|
-
price = ''
|
85
|
+
price = ''**
|
86
86
|
|
87
87
|
|
88
88
|
|
@@ -90,15 +90,13 @@
|
|
90
90
|
|
91
91
|
import csv
|
92
92
|
|
93
|
-
import sys
|
94
|
-
|
95
93
|
|
96
94
|
|
97
95
|
from bs4 import BeautifulSoup
|
98
96
|
|
99
97
|
|
100
98
|
|
101
|
-
url = 'http://
|
99
|
+
url = 'http://'
|
102
100
|
|
103
101
|
html = requests.get(url)
|
104
102
|
|
@@ -108,21 +106,27 @@
|
|
108
106
|
|
109
107
|
span = soup.find_all("span",{"class":"price"})
|
110
108
|
|
111
|
-
print(span)
|
112
|
-
|
113
109
|
|
114
110
|
|
115
111
|
for i in span:
|
116
112
|
|
117
|
-
|
113
|
+
print(i.string)
|
118
114
|
|
119
|
-
|
115
|
+
b =(i.string)
|
120
116
|
|
121
117
|
|
122
118
|
|
123
|
-
|
119
|
+
a_list = []
|
124
120
|
|
121
|
+
a_list.append(b)
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
f = open('some.csv', 'w')
|
126
|
+
|
127
|
+
writer = csv.writer(f)
|
128
|
+
|
125
|
-
|
129
|
+
writer.writerow(a_list)
|
126
130
|
|
127
131
|
|
128
132
|
|
1
アドバイス頂いた後にトライしているコードを更新いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -75,3 +75,55 @@
|
|
75
75
|
writer = csv.writer(f, lineterminator='\n')
|
76
76
|
|
77
77
|
writer.writerow(a)
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```**ここからアドバイス頂いた後トライしているもの
|
84
|
+
|
85
|
+
price = ''
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
import requests
|
90
|
+
|
91
|
+
import csv
|
92
|
+
|
93
|
+
import sys
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
from bs4 import BeautifulSoup
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
url = 'http://kakaku.com/kuruma/used/spec/Maker=1/Model=31773'
|
102
|
+
|
103
|
+
html = requests.get(url)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
soup = BeautifulSoup(html.text,"html.parser")
|
108
|
+
|
109
|
+
span = soup.find_all("span",{"class":"price"})
|
110
|
+
|
111
|
+
print(span)
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
for i in span:
|
116
|
+
|
117
|
+
a = float(i.string)
|
118
|
+
|
119
|
+
print(a)
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
writer = csv.writer(sys.stdout)
|
124
|
+
|
125
|
+
_ = writer.writerow([a])
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|