Created
May 15, 2014 17:10
-
-
Save alumican/d81d074a1ff0c5de183c to your computer and use it in GitHub Desktop.
ネーコンのねこツイート
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
# -*- coding: utf-8 -*- | |
import mechanize | |
from BeautifulSoup import BeautifulSoup | |
import tweepy | |
SHINDAN_URL = "http://shindanmaker.com/322469" | |
TWITTER_USERNAME = "username" | |
TWITTER_API_KEY = "*****************************" | |
TWITTER_API_SECRET = "*****************************" | |
TWITTER_ACCESS_TOKEN = "*****************************" | |
TWITTER_ACCESS_TOKEN_SECRET = "*****************************" | |
class Main: | |
def __init__(self): | |
browser = mechanize.Browser() | |
browser.open(SHINDAN_URL) | |
browser.select_form(name = "enter") | |
browser["u"] = TWITTER_USERNAME | |
response = browser.submit() | |
soup = BeautifulSoup(response.read()) | |
tweetBody = soup.find('form', attrs = { 'id' : 'forcopy' }).textarea.text | |
auth = tweepy.OAuthHandler(TWITTER_API_KEY, TWITTER_API_SECRET) | |
auth.set_access_token(TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET) | |
api = tweepy.API(auth) | |
api.update_status(tweetBody) | |
if __name__ == "__main__": | |
Main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment