Skip to content

Instantly share code, notes, and snippets.

@alumican
Created May 15, 2014 17:10
Show Gist options
  • Save alumican/d81d074a1ff0c5de183c to your computer and use it in GitHub Desktop.
Save alumican/d81d074a1ff0c5de183c to your computer and use it in GitHub Desktop.
ネーコンのねこツイート
#!/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