質問編集履歴
1
文章の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,23 +1,38 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
VisualStudioCodeでpythonのスクレイピングのコードを書いていています。不動産サイト、スーモのurlのhttps://suumo.jp/chintai/tokyo/sc_shinjuku/からrequestsモジュールとBeautifulSoupを用いてHTMLのコードを読み込み物件名、住所、アクセス方法、築年数を持ってきたいので
|
2
|
+
VisualStudioCodeでpythonのスクレイピングのコードを書いていています。不動産サイト、スーモのurlのhttps://suumo.jp/chintai/tokyo/sc_shinjuku/からrequestsモジュールとBeautifulSoupを用いてHTMLのコードを読み込み物件名、住所、アクセス方法、築年数を持ってきたいので以下のようなコードを書きました。
|
3
3
|
|
4
|
-
###
|
4
|
+
### ソースコード
|
5
5
|
|
6
|
-
```title = detail.find('div', class_='cassetteitem_content-title').text
|
7
|
-
TypeError: find() takes no keyword arguments
|
8
|
-
エラーメッセージ
|
9
|
-
```
|
6
|
+
```python
|
7
|
+
from bs4 import BeautifulSoup
|
8
|
+
import requests
|
10
9
|
|
10
|
+
url = 'https://suumo.jp/chintai/tokyo/sc_shinjuku/?page={}'
|
11
|
-
|
11
|
+
target_url = url.format(1)
|
12
|
+
r = requests.get(target_url)
|
13
|
+
soup = BeautifulSoup(r.text)
|
12
14
|
|
15
|
+
contents = soup.find_all('div', class_='cassetteitem')
|
13
|
-
|
16
|
+
content = contents[0]
|
17
|
+
|
14
|
-
|
18
|
+
detail = content.find('div', class_='cassetteitem-detail').text
|
19
|
+
table = content.find('table', class_='cassetteitem_other').text
|
20
|
+
|
21
|
+
title = detail.find('div', class_='cassetteitem_content-title').text
|
22
|
+
address = detail.find('li', class_='cassetteitem_detail-col1').text
|
23
|
+
access = detail.find('li', class_='cassetteitem_detail-col2').text
|
24
|
+
age = detail.find('li', class_='cassetteitem_detail-col3').text
|
15
25
|
```
|
26
|
+
ですが、以下のようなエラーが出てしまいました。
|
27
|
+
### エラーメッセージ
|
28
|
+
```
|
29
|
+
title = detail.find('div', class_='cassetteitem_content-title').text
|
30
|
+
TypeError: find() takes no keyword arguments
|
16
31
|
|
17
|
-
|
32
|
+
```
|
18
33
|
|
19
|
-
ここに問題に対して試したことを記載してください。
|
20
34
|
|
21
35
|
### 補足情報(FW/ツールのバージョンなど)
|
22
36
|
|
23
|
-
|
37
|
+
python 3.8.5 64-bit
|
38
|
+
VisualStudioCode使用
|