Author Topic: [py] script f'ing up?  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Offline hmm

  • Serf
  • *
  • Posts: 23
  • Cookies: 0
    • View Profile
[py] script f'ing up?
« on: August 25, 2012, 09:43:17 pm »
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.
Code: (python) [Select]

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)
« Last Edit: August 26, 2012, 12:16:54 pm by hmm »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [py] script f'ing up?
« Reply #1 on: August 26, 2012, 11:53:31 am »
Well then can you describe the error in more detail? maybe copy it from the output?

Offline hmm

  • Serf
  • *
  • Posts: 23
  • Cookies: 0
    • View Profile
Re: [py] script f'ing up?
« Reply #2 on: August 26, 2012, 12:06:04 pm »
No output, thats really the dig. On any of my issues. They simply don't produce. Note:if you test it I still have to mess with preciously sent tweets, but I should be able to handle that, and it won't effect the above problems.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [py] script f'ing up?
« Reply #3 on: August 26, 2012, 12:35:46 pm »
Did you bother to use the debugger and follow the code? I suggest using Eclipse and PyDev plugin, it has a built-in debugger.

Offline hmm

  • Serf
  • *
  • Posts: 23
  • Cookies: 0
    • View Profile
Re: [py] script f'ing up?
« Reply #4 on: August 29, 2012, 05:56:25 am »
I shall try this in a few days, however, my kind had to do with my computer falling asleep? Very strange. Multi-processing/threading still do not work, though I'll try playing around with them a little more post debugger.