質問編集履歴
2
GitHub追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -51,4 +51,7 @@
|
|
51
51
|
print(soup.title)
|
52
52
|
f1 = open('r.txt', 'w')
|
53
53
|
f1.write(html_doc)
|
54
|
-
```
|
54
|
+
```
|
55
|
+
|
56
|
+
# GitHubにも上げました!
|
57
|
+
[O'Reilly Scraping](https://github.com/Yukiya025/CommerceScraper)
|
1
完成コード追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,4 +32,23 @@
|
|
32
32
|
<tr><td>4-87311-061-0</td><td id="4873110610" class="title"><a href="../books/4873110610/">Javaネットワークプログラミング 第2版</a></td><td class="price">6,264 </td><td>2001/10/01</td></tr>
|
33
33
|
```
|
34
34
|
|
35
|
-

|
35
|
+

|
36
|
+
|
37
|
+
# できましたー(≧∇≦)
|
38
|
+
hayataka2049様のアドバイスで`r.encoding = r.apparent_encoding`を追加したら日本語がきちんと表示されるようになりました<3
|
39
|
+
|
40
|
+
**完成コード**
|
41
|
+
```
|
42
|
+
import requests
|
43
|
+
import warnings
|
44
|
+
warnings.filterwarnings('ignore')
|
45
|
+
r = requests.get("https://www.oreilly.co.jp/catalog/")
|
46
|
+
r.encoding = r.apparent_encoding
|
47
|
+
|
48
|
+
html_doc = r.text
|
49
|
+
soup = BeautifulSoup(html_doc)
|
50
|
+
|
51
|
+
print(soup.title)
|
52
|
+
f1 = open('r.txt', 'w')
|
53
|
+
f1.write(html_doc)
|
54
|
+
```
|