回答編集履歴
2
Update
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
r = requests.get(page_url, headers=headers)
|
12
12
|
soup = BeautifulSoup(r.content, 'lxml')
|
13
|
-
img_tag = soup.select_one('div
|
13
|
+
img_tag = soup.select_one('div.book-cover > img')
|
14
14
|
img_url = img_tag['src']
|
15
15
|
print(img_url)
|
16
16
|
|
1
Update
test
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
|
1
|
+
`User-Agent` を設定する必要がある様です。
|
2
2
|
```python
|
3
3
|
import requests
|
4
|
-
import re
|
5
|
-
import
|
4
|
+
from bs4 import BeautifulSoup
|
6
5
|
|
7
6
|
page_url = "https://www.sciencedirect.com/book/9780124157590/haschek-and-rousseauxs-handbook-of-toxicologic-pathology"
|
8
7
|
headers = {
|
@@ -10,11 +9,12 @@
|
|
10
9
|
}
|
11
10
|
|
12
11
|
r = requests.get(page_url, headers=headers)
|
13
|
-
|
12
|
+
soup = BeautifulSoup(r.content, 'lxml')
|
14
|
-
if m:
|
15
|
-
|
13
|
+
img_tag = soup.select_one('div[class^="cover"] img')
|
14
|
+
img_url = img_tag['src']
|
16
|
-
|
15
|
+
print(img_url)
|
17
16
|
|
18
17
|
#
|
19
18
|
https://ars.els-cdn.com/content/image/3-s2.0-C20101678509-cov200h.gif
|
20
19
|
```
|
20
|
+
|