質問編集履歴

3

タイトルのエラー文言も修正

2018/12/25 01:16

投稿

hanlio
hanlio

スコア14

test CHANGED
@@ -1 +1 @@
1
- bitbarで「ImportError: No module named 'BeautifulSoup'」となる
1
+ bitbarで「ImportError: No module named 'bs4'」となる
test CHANGED
File without changes

2

エラー文言修正

2018/12/25 01:15

投稿

hanlio
hanlio

スコア14

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- 上記ディレクトリで、実行すると正常に動作するのですが、`bitbar`では`ImportError: No module named 'BeautifulSoup'`と表示されます。
5
+ 上記ディレクトリで、実行すると正常に動作するのですが、`bitbar`では`ImportError: No module named 'bs4'`と表示されます。
6
6
 
7
7
 
8
8
 

1

事象の詳細記載

2018/12/25 01:15

投稿

hanlio
hanlio

スコア14

test CHANGED
@@ -1 +1 @@
1
- bitbarのプラグインディレクトリだと、「ImportError: No module named 'BeautifulSoup4'」となる
1
+ bitbar「ImportError: No module named 'BeautifulSoup'」となる
test CHANGED
@@ -1,16 +1,142 @@
1
- 1. 作業ディレクトリ:`~/Cord/movieScraping`
2
-
3
- 2. bitbarnプラグインのディレクトリ:`~/Documents/bitbar_plugins`
1
+ bitbarプラグインのディレクトリ:`~/Documents/bitbar_plugins`
4
2
 
5
3
 
6
4
 
7
- `1`で動作することを確認したファイルを`2`に移したところ、`ImportError: No module named 'BeautifulSoup4'`と表示されました
5
+ 上記ディレクトリ、実行すると正常に動作するのですが、`bitbar`では`ImportError: No module named 'BeautifulSoup'`と表示されま
8
6
 
9
7
 
10
8
 
11
- なぜなのでしょうか。
9
+ これはなぜなのでしょうか。
12
10
 
13
11
 
12
+
13
+ ## 事象の画像
14
+
15
+ ![イメージ説明](7f91f193168c9399aa4946231c8b432c.png)
16
+
17
+
18
+
19
+ ## コード
20
+
21
+ ```python
22
+
23
+ #!/usr/bin/env python
24
+
25
+
26
+
27
+ # <bitbar.title>Movie Scheduler</bitbar.title>
28
+
29
+ # <bitbar.version>v1.0</bitbar.version>
30
+
31
+ # <bitbar.author>hanlio</bitbar.author>
32
+
33
+ # <bitbar.author.github>hanlio</bitbar.author.github>
34
+
35
+ # <bitbar.dependencies>python</bitbar.dependencies>
36
+
37
+
38
+
39
+ # coding: UTF-8
40
+
41
+ import urllib2
42
+
43
+ import datetime
44
+
45
+ from bs4 import BeautifulSoup
46
+
47
+
48
+
49
+ # Access URL
50
+
51
+ url = "http://movie.zashiki.com/calendar/gw/201812.html"
52
+
53
+
54
+
55
+ # url remake html
56
+
57
+ html = urllib2.urlopen(url)
58
+
59
+
60
+
61
+ # html to BeautifulSoup
62
+
63
+ soup = BeautifulSoup(html, "html.parser")
64
+
65
+
66
+
67
+ # get title
68
+
69
+ title = soup.title.string
70
+
71
+
72
+
73
+ print title
74
+
75
+
76
+
77
+ # get all tr
78
+
79
+ tr = soup.find_all("tr")
80
+
81
+
82
+
83
+ # get movie title
84
+
85
+ movie_title = []
86
+
87
+
88
+
89
+ # today
90
+
91
+ dt_now = datetime.datetime.now()
92
+
93
+ today = dt_now.strftime('%d')
94
+
95
+
96
+
97
+ # find tr
98
+
99
+ for tagTR in tr:
100
+
101
+ try:
102
+
103
+ date = tagTR.find("td", "date").string
104
+
105
+ if date:
106
+
107
+ if date.find(today + '(') > 0:
108
+
109
+ movie_title = []
110
+
111
+ movie_title.append(tagTR.find("td", "date").string)
112
+
113
+
114
+
115
+ time = tagTR.find("td", "time").string
116
+
117
+ title = tagTR.find("td", "title").string
118
+
119
+ movie_title.append( time + " | " + title)
120
+
121
+ pass
122
+
123
+
124
+
125
+ except Exception as e:
126
+
127
+ pass
128
+
129
+
130
+
131
+ for t in movie_title:
132
+
133
+ print t
134
+
135
+ ```
136
+
137
+
138
+
139
+ ## バージョン情報
14
140
 
15
141
  ```shell
16
142
 
@@ -38,12 +164,4 @@
38
164
 
39
165
  wheel 0.31.0
40
166
 
41
-
42
-
43
-
44
-
45
- $ python -c "import bs4"
46
-
47
- #特にエラーなし
48
-
49
167
  ```