質問編集履歴
1
コードの見辛い部分を修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,8 +17,6 @@
|
|
17
17
|
|
18
18
|
### 該当のソースコード
|
19
19
|
|
20
|
-
#coding: UTF-8
|
21
|
-
|
22
20
|
import ssl
|
23
21
|
ssl._create_default_https_context = ssl._create_unverified_context
|
24
22
|
|
@@ -27,20 +25,16 @@
|
|
27
25
|
from bs4 import BeautifulSoup
|
28
26
|
|
29
27
|
def scraping():
|
30
|
-
|
28
|
+
|
31
29
|
url = "https://books.rakuten.co.jp/"
|
32
30
|
|
33
|
-
#get html
|
34
31
|
html = request.urlopen(url)
|
35
32
|
|
36
|
-
#set BueatifulSoup
|
37
33
|
soup = BeautifulSoup(html, "html.parser")
|
38
34
|
|
39
|
-
#get headlines
|
40
35
|
mainNewsIndex = soup.find("div", attrs={"style", "margin: 10px 0;padding: 8px; background: #ff9900;font-size: 15px; font-weight: bold; text-align: center; z-index: 0;color: #330000;" })
|
41
36
|
headlines = mainNewsIndex.find_all("span", attrs={"style", "color: #ffffff;"})
|
42
37
|
|
43
|
-
#print headlines
|
44
38
|
print(headlines)
|
45
39
|
|
46
40
|
scraping()
|