So this is part of my forum spamming project, so I didn't know if I should post here or there, but it's ultimately a python question. My script kind of gets snagged randomly, i.e, i'll test for all accts. and its fine-n-dandy, and when it comes time to run it all together it makes it through like 3 and then gets f'd. I'd also like to multi-proccess/multi-thread this, so I can have multiple accts going at one, but even when trying to thread, it halts after the login step, and I cant even get multi-processing to work. I tried to just run the python example script(see there website) and got no values printed out.
from urllib import urlopen
import re
import string
from twitter import *
import random
import time
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import threading
usr=[]##list of usernames
pw = ##a password
tweets=[]
f = open('ap.txt', 'r')
for line in f:
line = line.decode('utf-8')
if len(line)>120:
front= len(line)-120
line = line[front:]
tweets.append(line)
while(True):
for item in usr:
browser = webdriver.Firefox()
browser.get("http://www.twitter.com/")
elem = browser.find_element_by_css_selector(".text-input.email-input")
elem.send_keys(item)
elem = browser.find_element_by_css_selector(".text-input.flex-table-input")
elem.send_keys(pw)
browser.find_element_by_css_selector(".submit.btn.primary-btn.flex-table-btn.js-submit").click()
time.sleep(2)
##the below only works on one thread, when I attempt to thread.
for i in range(0,15):
temp=[]
t = random.choice(tweets)
if t in temp:
while(t in temp):
t = random.choice(tweets)
temp.append(t)
t = 'F'
while(t == 'F'):
try:
browser.find_element_by_class_name("twitter-anywhere-tweet-box-editor").send_keys(t)
t = 'T'
except:
time.sleep(.1)
t='F'
time.sleep(2)
while(t=='F'):
try:
browser.find_element_by_css_selector(".tweet-button.btn.primary-btn").click()
t = 'T'
except:
time.sleep(.1)
time.sleep(15)
browser.find_element_by_xpath(".//*[@id='page-node-home'][1][5][2]/ul/li[2]/a").click()
browser.find_element_by_class_name("toggle-item-2 ").click()
time.sleep(2)
##below is where my random snag is happening. I believe.
peeps = browser.find_elements_by_css_selector(".account-group.js-account-group.js-action-profile.js-user-profile-link")
for i in range(0,10):
peeps[i].click()
while(True):
try:
browser.find_element_by_css_selector(".js-action-follow.follow-text.action-text").click()
break
except:
time.sleep(.1)
browser.find_element_by_class_name("twttr-dialog-close").click()
time.sleep(1)
browser.close()
time.sleep(100)