Browse Source

complete rework

master
calexil 3 years ago
parent
commit
52be5c651d
6 changed files with 49 additions and 58 deletions
  1. 6
    5
      README.md
  2. 0
    53
      clrenew.py
  3. BIN
      myaccount.png
  4. BIN
      page2.png
  5. BIN
      renew.png
  6. 43
    0
      renew.py

+ 6
- 5
README.md View File

@@ -1,17 +1,18 @@
# CLRenew
A simple python script to log into your craigslist account and renew any listings that can be renewed.
A simple python script to click through your craigslist account and renew any listings that can be renewed.

##Requirements
You will need selenium and ChromeDriver
You will need pyautogui and python-tk

* `pip install selenium`
* `sudo apt install python3-tk python3-dev python-tk`

* `sudo pip install python3-xlib pyautogui`

* [Download ChromeDriver from here](https://sites.google.com/a/chromium.org/chromedriver/downloads) and put it in your /usr/bin/ directory.

## Usage
Simple clone the repo and run clrenew.py in terminal:

`python clrenew.py`
`python renew.py`

## Notes


+ 0
- 53
clrenew.py View File

@@ -1,53 +0,0 @@
#Welcome to clrenew, a tool to renew your craigslist listings
import os
import time
from os.path import expanduser
home = expanduser("~")
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--user-data-dir=%s' % os.path.join(os.path.expanduser("~"), ".config/chromium/Default" ) )


# Find Renew links and click them
driver = webdriver.Chrome(chrome_options=options)


url0="https://accounts.craigslist.org/login/home"
url1="https://accounts.craigslist.org/login/home?filter_page=1"
url2="https://accounts.craigslist.org/login/home?filter_page=2"

driver.get(url0)

try:
time.sleep(5)
driver.get(url1)
element = driver.find_element_by_xpath("//*[@id='paginator']/table/tbody/tr[1]/td[2]/div/form[3]/input[3]")
element.click()
time.sleep(5)
element = driver.find_element_by_xpath("//*[@id='paginator']/table/tbody/tr[2]/td[2]/div/form[3]/input[3]")
element.click()
time.sleep(10)
except Exception as e:
print e




print "done, trying next page"

#run it again
try:
time.sleep(5)
driver.get(url2)
element = driver.find_element_by_xpath("//*[@id='paginator']/table/tbody/tr[1]/td[2]/div/form[3]/input[3]")
element.click()
time.sleep(5)
element = driver.find_element_by_xpath("//*[@id='paginator']/table/tbody/tr[2]/td[2]/div/form[3]/input[3]")
element.click()
time.sleep(5)
except Exception as e:
print e

print "done, your renewal is complete."
driver.quit()

BIN
myaccount.png View File


BIN
page2.png View File


BIN
renew.png View File


+ 43
- 0
renew.py View File

@@ -0,0 +1,43 @@
#!/usr/bin/python
#Welcome to CLRenew, a simple python script that automates mouse clicks to renew craigslist postings, credit to https://github.com/yuqianli for the base code
import pyautogui
import os
#Set a counter to count the # of exceptions occur
counter = 0

#Start the while loop
while True:
try:
print ("Be sure your active listings page is up and active")
pyautogui.time.sleep(2)
renewButtonLocationX,renewButtonLocationY = pyautogui.locateCenterOnScreen('renew.png')
pyautogui.moveTo(renewButtonLocationX, renewButtonLocationY)
pyautogui.click()
pyautogui.time.sleep(2)
#This part of the loop will depend on your browser binding to go back a page, in chrome/chromium use this:
pyautogui.keyDown('alt')
pyautogui.press('left')
pyautogui.keyUp('alt')

pyautogui.time.sleep(2)

# Exception handle when pyautogui can't locate the renew button on the screen or if it clicks away by mistake
# this section needs work and sometimes fails to function properly
except Exception:
print ("Exception thrown, calculating course of action")
pyautogui.press('pgdn')
counter += 1
print ("counter =" + str(counter))
if counter >=5: counter = 0
if counter >=4:
pyautogui.time.sleep(2)
renewButtonLocationX,renewButtonLocationY = pyautogui.locateCenterOnScreen('myaccount.png')
pyautogui.moveTo(renewButtonLocationX, renewButtonLocationY)
pyautogui.click()
pyautogui.time.sleep(2)
if counter >=3:
pyautogui.time.sleep(2)
renewButtonLocationX,renewButtonLocationY = pyautogui.locateCenterOnScreen('page2.png')
pyautogui.moveTo(renewButtonLocationX, renewButtonLocationY)
pyautogui.click()
pyautogui.time.sleep(2)

Loading…
Cancel
Save