質問編集履歴
1
成功コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -55,3 +55,31 @@
|
|
55
55
|
TypeError: a bytes-like object is required, not 'Response'
|
56
56
|
|
57
57
|
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
下記コードにて成功しました。
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```python
|
68
|
+
|
69
|
+
soup = BeautifulSoup(res.text, 'html.parser')
|
70
|
+
|
71
|
+
img_tags = soup.find_all('img')
|
72
|
+
|
73
|
+
for i, imag_tag in enumerate(img_tags):
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
root_url = 'https://scraping-for-beginner.herokuapp.com'
|
78
|
+
|
79
|
+
img_url = root_url + img_tag['src']
|
80
|
+
|
81
|
+
img = Image.open(io.BytesIO(requests.get(img_url).content))
|
82
|
+
|
83
|
+
img.save(f'img/{i}.jpg')
|
84
|
+
|
85
|
+
```
|