質問編集履歴

1

コードの見辛い部分を修正

2018/09/03 16:39

投稿

asui9625
asui9625

スコア11

test CHANGED
File without changes
test CHANGED
@@ -36,10 +36,6 @@
36
36
 
37
37
 
38
38
 
39
- #coding: UTF-8
40
-
41
-
42
-
43
39
  import ssl
44
40
 
45
41
  ssl._create_default_https_context = ssl._create_unverified_context
@@ -56,33 +52,25 @@
56
52
 
57
53
  def scraping():
58
54
 
59
- #url
55
+
60
56
 
61
57
  url = "https://books.rakuten.co.jp/"
62
58
 
63
59
 
64
60
 
65
- #get html
66
-
67
61
  html = request.urlopen(url)
68
62
 
69
63
 
70
64
 
71
- #set BueatifulSoup
72
-
73
65
  soup = BeautifulSoup(html, "html.parser")
74
66
 
75
67
 
76
-
77
- #get headlines
78
68
 
79
69
  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;" })
80
70
 
81
71
  headlines = mainNewsIndex.find_all("span", attrs={"style", "color: #ffffff;"})
82
72
 
83
73
 
84
-
85
- #print headlines
86
74
 
87
75
  print(headlines)
88
76