Skip to content

Instantly share code, notes, and snippets.

@alexin-ivan
Created January 1, 2014 01:32
Show Gist options
  • Save alexin-ivan/8204013 to your computer and use it in GitHub Desktop.
Save alexin-ivan/8204013 to your computer and use it in GitHub Desktop.
Взято отсюда: https://github.com/Sild/habrasiski Переписано на питоне
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from selenium import webdriver
import time
import sys
import random
from selenium.webdriver.common.keys import Keys
SITE = "http://chat.mibbit.com/?server=irc.p2pchat.net&channel=%23habr2014ny"
LOGIN_FIELD = '//*[@id="f_nick2"]'
ENTER = '//*[@id="ircconnectform2"]/form/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[6]/input'
INPUT_FIELD = '//*[@id="chats"]/div[3]/div[5]/div[1]/div[1]/form/input'
def main():
login = 'new_boobs'
wait_time = 60 * 2
driver = webdriver.Firefox()
driver.get(SITE)
lf = driver.find_element_by_xpath(LOGIN_FIELD)
lf.clear()
lf.send_keys(login)
driver.find_element_by_xpath(ENTER).click()
try:
time.sleep(5)
except KeyboardInterrupt:
print 'exiting'
sys.exit(0)
imax = 7500
imin = 6000
irand = 0
print 'Start'
while True:
irand = imin + int((random.random() * ((imax - imin) + 1)))
url = "http://media.oboobs.ru/boobs/0" + str(irand) + ".jpg"
lf = driver.find_element_by_xpath(INPUT_FIELD)
lf.send_keys(url)
lf.send_keys(Keys.RETURN)
try:
time.sleep(wait_time)
except Exception, e:
print e.message
sys.exit(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment