-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraigslist.py
91 lines (68 loc) · 2.6 KB
/
craigslist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#read instructions at the end
from selenium import webdriver
import time
#driver object
driver = webdriver.Chrome('chromedriver.exe')
#use this function to click a button with id
def buttonClickById(id):
id = id
driver.find_element_by_id(id).click()
def buttonClickByClass(className):
name = className
driver.find_element_by_css_selector(name).click()
#use this function to input in a text field
def inputField(id, inputText):
id = id
inputText = inputText
driver.find_element_by_id(id).send_keys(inputText)
class craigslist_:
def __init__(self, email, password):
self.email = email
self.password = password
def login(self, emailPass):
driver.get("https://accounts.craigslist.org/login")
time.sleep(2)
inputField("inputEmailHandle", self.email)
time.sleep(1)
inputField("inputPassword", self.password)
time.sleep(1)
buttonClickById("login")
time.sleep(1)
buttonClickById("onetime")
#email verification here
time.sleep(10)
import linkFromGmail
link = linkFromGmail.fun(self.email, emailPass)
driver.get(link)
def posting(self, title, city, postal, description, contact_no):
driver.get("https://post.craigslist.org/c/dhn/C/act")
time.sleep(1)
inputField("PostingTitle", title)
time.sleep(1)
inputField("GeographicArea", city)
time.sleep(1)
inputField("postal_code", postal)
time.sleep(1)
inputField("PostingBody", description)
time.sleep(1)
buttonClickByClass(".go.big-button.submit-button")
time.sleep(1)
#posting 2nd page
buttonClickByClass(".continue.bigbutton")
time.sleep(1)
#positn 3rd page
buttonClickByClass(".bigbutton")
time.sleep(1)
#phone number page
#posting FUNCTION is not complete yet
ob1 = craigslist_("EMAIL", "CRAIGSLIST_PASSWORD")
ob1.login("PASSWORD_OF_EMAIL_ACCOUNT")
ob1.posting("Posting title", "Dothan", "36345", "Description about the post will go here", "XXXXXXXXXX")
'''
First create an object with EMAIL and PASSWORD
ob1 = craigslist_("EMAIL", "CRAIGSLIST_PASSWORD")
then, to login, call the login FUNCTION. It'll do the email verification automatically
ob1.login("PASSWORD_OF_EMAIL_ACCOUNT")
to post, call the post FUNCTION with TITLE, CITY, POSTAL CODE, DESCRIPTION and CONTACT_NO
ob1.posting("Posting title", "Dothan", "36345", "Description about the post will go here", "XXXXXXXXXX")
'''