質問編集履歴

4

誤字修正しました

2019/05/08 13:19

投稿

hesitate.sheep
test CHANGED
File without changes
test CHANGED
@@ -78,6 +78,110 @@
78
78
 
79
79
 
80
80
 
81
+ 以下twitter_autoFavorite.pyのプログラムです。
82
+
83
+ ```
84
+
85
+ # Tweepyライブラリをインポート
86
+
87
+ import tweepy
88
+
89
+ # 各種キーをセット
90
+
91
+ CONSUMER_KEY = 'xxx'
92
+
93
+ CONSUMER_SECRET = 'xxx'
94
+
95
+ ACCESS_TOKEN = 'xxx'
96
+
97
+ ACCESS_SECRET = 'xxx'
98
+
99
+ auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
100
+
101
+ auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
102
+
103
+ #APIインスタンスを作成
104
+
105
+ api = tweepy.API(auth)
106
+
107
+
108
+
109
+ q = "python" #ここに検索キーワードを設定
110
+
111
+ count = 5
112
+
113
+ search_results = api.search(q=q, count=count)
114
+
115
+
116
+
117
+ def main():
118
+
119
+ for result in search_results:
120
+
121
+ username = result.user._json["screen_name"]
122
+
123
+ user_id = result.id #ツイートのstatusオブジェクトから、ツイートidを取得
124
+
125
+ print(user_id)
126
+
127
+ user = result.user.name #ツイートのstatusオブジェクトから、userオブジェクトを取り出し、名前を取得する
128
+
129
+ print(user)
130
+
131
+ tweet = result.text
132
+
133
+ print(tweet)
134
+
135
+ time = result.created_at
136
+
137
+ print(time)
138
+
139
+ try:
140
+
141
+ api.create_favorite(user_id) #ファヴォる
142
+
143
+ print(user)
144
+
145
+ print("をライクしました")
146
+
147
+ except:
148
+
149
+ print("もうすでにふぁぼしてますわ")
150
+
151
+ try:
152
+
153
+ api.create_friendship(username)#user_id
154
+
155
+ print(user)
156
+
157
+ print("をフォローしました")
158
+
159
+ except:
160
+
161
+ print("もうすでにフォローしてますわ")
162
+
163
+ try:
164
+
165
+ api.retweet(user_id) #RT
166
+
167
+ print(user_id)
168
+
169
+ print(tweet)
170
+
171
+ print("をRTしました")
172
+
173
+ except:
174
+
175
+ print("もうすでにRTしてますわ")
176
+
177
+ print("##################")
178
+
179
+
180
+
181
+ ```
182
+
183
+
184
+
81
185
  また、定期処理中は他のプログラムは実行出来ないのでしょうか?
82
186
 
83
187
  色々初心者で申し訳ないですがよろしくお願いします。

3

誤字修正しました

2019/05/08 13:19

投稿

hesitate.sheep
test CHANGED
File without changes
test CHANGED
@@ -52,19 +52,19 @@
52
52
 
53
53
  schedule.run_pending()
54
54
 
55
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
55
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
56
56
 
57
57
  default_scheduler.run_pending()
58
58
 
59
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
59
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
60
60
 
61
61
  self._run_job(job)
62
62
 
63
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
63
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
64
64
 
65
65
  ret = job.run()
66
66
 
67
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
67
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
68
68
 
69
69
  ret = self.job_func()
70
70
 

2

誤字修正しました

2019/05/07 00:12

投稿

hesitate.sheep
test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
  以下定期処理のプログラムです
12
12
 
13
+ ```
14
+
13
- ```import twitter_autoFavorite
15
+ import twitter_autoFavorite
14
16
 
15
17
  import schedule,time,datetime
16
18
 
@@ -42,29 +44,35 @@
42
44
 
43
45
  以下エラー文です。
44
46
 
47
+ ```
48
+
49
+ Traceback (most recent call last):
50
+
45
- ```File "Autoprogram.py", line 12, in <module>
51
+ File "Autoprogram.py", line 12, in <module>
46
52
 
47
53
  schedule.run_pending()
48
54
 
49
- File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
55
+ File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
50
56
 
51
57
  default_scheduler.run_pending()
52
58
 
53
- File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
59
+ File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
54
60
 
55
61
  self._run_job(job)
56
62
 
57
- File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
63
+ File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
58
64
 
59
65
  ret = job.run()
60
66
 
61
- File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
67
+ File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
62
68
 
63
69
  ret = self.job_func()
64
70
 
65
71
  File "Autoprogram.py", line 6, in job
66
72
 
67
73
  twitter_autoFavorite.main()
74
+
75
+ AttributeError: module 'twitter_autoFavorite' has no attribute 'main'
68
76
 
69
77
  ```
70
78
 

1

脱字修正しました

2019/05/07 00:07

投稿

hesitate.sheep
test CHANGED
File without changes
test CHANGED
@@ -46,19 +46,19 @@
46
46
 
47
47
  schedule.run_pending()
48
48
 
49
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
49
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 563, in run_pending
50
50
 
51
51
  default_scheduler.run_pending()
52
52
 
53
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
53
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 94, in run_pending
54
54
 
55
55
  self._run_job(job)
56
56
 
57
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
57
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 147, in _run_job
58
58
 
59
59
  ret = job.run()
60
60
 
61
- File "/Users/sakamotoren/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
61
+ File "/Users/me/.pyenv/versions/3.7.3/lib/python3.7/site-packages/schedule/__init__.py", line 466, in run
62
62
 
63
63
  ret = self.job_func()
64
64