質問編集履歴

1

ほぼすべて

2019/05/09 03:25

投稿

bokunokaminoke
bokunokaminoke

スコア10

test CHANGED
File without changes
test CHANGED
@@ -1,75 +1,107 @@
1
+ なぜかtweetするようなcodeではないにもかかわらず
2
+
3
+ 以下のエラーが発生してしまいます。
4
+
5
+
6
+
7
+ #認証以降は他のコードを試しても同じエラーがでます。
8
+
9
+ よろしくお願いします。
10
+
11
+
12
+
13
+ Traceback (most recent call last):
14
+
15
+ File "a.py", line 14, in <module>
16
+
17
+ api.update_status(status='test')
18
+
19
+ File "C:\Users\tatsuki kaneko\scraping\lib\site-packages\tweepy\api.py", line 195, in update_status
20
+
21
+ )(post_data=post_data, *args, **kwargs)
22
+
23
+ File "C:\Users\tatsuki kaneko\scraping\lib\site-packages\tweepy\binder.py", line 250, in _call
24
+
25
+ return method.execute()
26
+
27
+ File "C:\Users\tatsuki kaneko\scraping\lib\site-packages\tweepy\binder.py", line 234, in execute
28
+
29
+ raise TweepError(error_msg, resp, api_code=api_error_code)
30
+
31
+ tweepy.error.TweepError: [{'code': 187, 'message': 'Status is a duplicate.'}]
32
+
33
+
34
+
35
+ ```python
36
+
1
37
  import tweepy
2
38
 
3
39
 
4
40
 
41
+
42
+
43
+ consumer_key = "************************"
44
+
45
+ consumer_secret = "************************"
46
+
5
- def tweet():
47
+ access_token = "************************"
48
+
49
+ access_secret = "************************"
6
50
 
7
51
 
8
52
 
9
- consumer_key =
53
+ #認証
10
54
 
11
- consumer_secret =
55
+ auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
12
56
 
13
- access_token =
57
+ auth.set_access_token(access_token, access_secret)
14
58
 
15
- access_secret =
59
+ api = tweepy.API(auth)
60
+
61
+ api.update_status(status='test')
16
62
 
17
63
 
18
64
 
19
- auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
20
-
21
- auth.set_access_token(access_token, access_secret)
65
+ #wordをつぶやいている人をファボしてフォロー
22
66
 
23
67
 
24
68
 
25
- api = tweepy.API(auth)
69
+ word = ["practice",]
70
+
71
+ set_count = 10
72
+
73
+ results = api.search(q=word, count=set_count)
26
74
 
27
75
 
28
76
 
77
+ for result in results:
78
+
29
- api.update_status(status='test')
79
+ username = result.user._json['screen_name']
80
+
81
+ user_id = result.id
82
+
83
+ print("user_id:"+str(user_id))
84
+
85
+ user = result.user.name
86
+
87
+ print("user_name:"+user)
88
+
89
+ tweet = result.text
90
+
91
+ print("user_comments:"+tweet)
30
92
 
31
93
 
32
94
 
33
- word = ["practice",]
95
+ try:
34
96
 
35
- set_count = 10
97
+ api.create_favorite(user_id)
36
98
 
37
- results = api.search(q=word, count=set_count)
99
+ api.create_friendship(username)
38
100
 
101
+ print(user+"followed and favorite his tweet\n\n")
39
102
 
103
+ except:
40
104
 
41
- for result in results:
105
+ print(user+"already followed\n\n")
42
106
 
43
- username = result.user._json['screen_name']
44
-
45
- user_id = result.id
46
-
47
- print("user_id:"+str(user_id))
48
-
49
- user = result.user.name
50
-
51
- print("user_name:"+user)
52
-
53
- tweet = result.text
54
-
55
- print("user_comments:"+tweet)
56
-
57
-
58
-
59
- try:
107
+ ```
60
-
61
- api.create_favorite(user_id)
62
-
63
- api.create_friendship(username)
64
-
65
- print(user+"followed and favorite his tweet\n\n")
66
-
67
- except:
68
-
69
- print(user+"already followed\n\n")
70
-
71
-
72
-
73
- if __name__ == '__main__':
74
-
75
- tweet()