プロネットサーファーへの道

# coding:utf-8
import google
import os
from time import sleep
from selenium import webdriver
from requests_oauthlib import OAuth1Session
import json
import settings

twitter = OAuth1Session(settings.CONSUMER_KEY, settings.CONSUMER_SECRET, settings.ACCESS_TOKEN, settings.ACCESS_TOKEN_SECRET)

params = {}
req = twitter.get(“https://api.twitter.com/1.1/statuses/home_timeline.json”, params = params)

timeline = json.loads(req.text)

for tweet in timeline:
term = str(tweet[“text”].encode(“utf-8”))[:10]
f = google.search(term, lang = ‘ja’,num = 2,stop = 1)
F = google.search(term, lang = ‘en’,num = 2,stop = 1)

#print(‘Quick search URL result bellow\n’)
list = [url for url in f]
list2 = [url for url in F]
# print(url)

driver = webdriver.Chrome()
driver.get(list[0])
driver.set_window_position(0,0)
driver.set_window_size(1000,500)

river = webdriver.Chrome()
river.get(list[1])
river.set_window_position(1000,510)
river.set_window_size(1000,500)

iver = webdriver.Chrome()
iver.get(list2[0])
iver.set_window_position(0,510)
iver.set_window_size(1000,500)

ver = webdriver.Chrome()
ver.get(list2[1])
ver.set_window_position(1000,0)
ver.set_window_size(1000,500)

sleep(30)
driver.quit()
river.quit()
iver.quit()
ver.quit()

相変わらず適当ですがスニペットをどうぞ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s