コード例 #1
0
ファイル: __main__.py プロジェクト: CodeThat/Web_Bots
    def createPost(self):
        if not self.isLoggedIn:
            return 0

        self.debug("Navigating to post page")
        self.client.get("http://losangeles.craigslist.org/search/sgv/cps")
        self.client.find_element_by_css_selector(".post a.no-mobile").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='so']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='76']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='4']").click()
        time.sleep(self.waitTime)

        self.debug("Trying to fill in email")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(
                self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(
                self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")

        self.debug("Checking 'Okay to contact by phone'")
        self.client.find_element_by_css_selector("#contact_phone_ok").click()
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact by text'")
        self.client.find_element_by_css_selector("#contact_text_ok").click()
        time.sleep(self.waitTime)
        self.debug("Filling in contact phone number")
        self.client.find_element_by_css_selector("#contact_phone").send_keys(
            self.contactNumber)
        time.sleep(self.waitTime)
        self.debug("Filling in contact name")
        self.client.find_element_by_css_selector("#contact_name").send_keys(
            self.contactName)
        time.sleep(self.waitTime)
        self.debug("Filling in post title")
        self.client.find_element_by_css_selector("#PostingTitle").send_keys(
            spintax.parse(self.postTitle))
        time.sleep(self.waitTime)
        self.debug("Filling in zip code")
        self.client.find_element_by_css_selector("#postal_code").send_keys(
            self.postCode)
        time.sleep(self.waitTime)

        self.debug("Getting post content")
        f = open(self.postContent, "rb")
        content = f.read()
        f.close()

        self.debug("Spinning content")
        spinContent = spintax.parse(content)

        self.debug("Filling in post content")
        self.client.find_element_by_css_selector("#PostingBody").send_keys(
            spinContent)
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact for other offers'")
        self.client.find_element_by_css_selector("#oc").click()
        time.sleep(self.waitTime)
        self.debug("Unchecking 'Want a map' if checked")
        try:
            self.client.find_element_by_css_selector("#wantamap:checked")
        except NoSuchElementException:
            self.debug("Not checked")
        finally:
            self.client.find_element_by_css_selector(
                "#wantamap:checked").click()
        time.sleep(self.waitTime)
        self.debug("Clicking continue")
        self.client.find_element_by_css_selector(
            'button[value="Continue"]').click()
        time.sleep(self.waitTime)
        if "editimage" in self.client.current_url:
            self.debug("Clicking continue")
            self.client.find_element_by_css_selector('button.done').click()
        time.sleep(self.waitTime)
        self.debug("Clicking publish")
        self.client.find_element_by_css_selector(
            '.draft_warning button[value="Continue"]').click()
        time.sleep(10)
コード例 #2
0
def GenerateSuperHeroName():
    SuperHeroName = spintax.parse(
        r"{The|One|A|}{Big|Large|Small|Tiny|Giant|Titanic|Massive}{Blue|Red|Green|Yellow|Purple|Violet|Rose|Black|White|Pink}{Dog|Cat|Pig|Cow|Chicken|Rabbit|Sheep|Duck|Goat|Elephant}{Is|IsNow|HasBeen|Was|WasJust|}{Happily|Gladly|Joyfully|}{Eating|Jumping|Running|Walking|Smiling|Playing|Laughing}"
    )
    return SuperHeroName[0]
コード例 #3
0
import spintax
import super_hero_name_generator

# Generate Super hero name
SuperHeroName = super_hero_name_generator.GenerateSuperHeroName()
# Generate greeting
SuperHeroText = r"""
{Hello|Hi|Hey}{,|} I{'| a}m \{0\}{,|!|!!!}
I {{come|am} {here|on this earth}|{came|travelled} {here|to this place}} to {protect|save} {humanity|the world|humans|civilization} {and {destroy|kill|eradicate|remove}|by {destroy|kill|eradicat|remov}ing} all {evil|badness|hate}.
"""
print(spintax.parse(SuperHeroText)[0].format(SuperHeroName))
# As the { and } were escaped this allowed us to use .format() to insert the name
コード例 #4
0
    def createPost(self):
        if not self.isLoggedIn:
            return 0

        self.debug("Navigating to post page")
        self.client.get("http://losangeles.craigslist.org/search/sgv/cps")
        self.client.find_element_by_css_selector(".post a.no-mobile").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='so']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='76']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='4']").click()
        time.sleep(self.waitTime)

        self.debug("Trying to fill in email")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")

        self.debug("Checking 'Okay to contact by phone'")
        self.client.find_element_by_css_selector("#contact_phone_ok").click()
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact by text'")
        self.client.find_element_by_css_selector("#contact_text_ok").click()
        time.sleep(self.waitTime)
        self.debug("Filling in contact phone number")
        self.client.find_element_by_css_selector("#contact_phone").send_keys(self.contactNumber)
        time.sleep(self.waitTime)
        self.debug("Filling in contact name")
        self.client.find_element_by_css_selector("#contact_name").send_keys(self.contactName)
        time.sleep(self.waitTime)
        self.debug("Filling in post title")
        self.client.find_element_by_css_selector("#PostingTitle").send_keys(spintax.parse(self.postTitle))
        time.sleep(self.waitTime)
        self.debug("Filling in zip code")
        self.client.find_element_by_css_selector("#postal_code").send_keys(self.postCode)
        time.sleep(self.waitTime)

        self.debug("Getting post content")
        f = open(self.postContent, "rb")
        content = f.read()
        f.close()

        self.debug("Spinning content")
        spinContent = spintax.parse(content)

        self.debug("Filling in post content")
        self.client.find_element_by_css_selector("#PostingBody").send_keys(spinContent)
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact for other offers'")
        self.client.find_element_by_css_selector("#oc").click()
        time.sleep(self.waitTime)
        self.debug("Unchecking 'Want a map' if checked")
        try:
            self.client.find_element_by_css_selector("#wantamap:checked")
        except NoSuchElementException:
            self.debug("Not checked")
        finally:
            self.client.find_element_by_css_selector("#wantamap:checked").click()
        time.sleep(self.waitTime)
        self.debug("Clicking continue")
        self.client.find_element_by_css_selector('button[value="Continue"]').click()
        time.sleep(self.waitTime)
        if "editimage" in self.client.current_url:
            self.debug("Clicking continue")
            self.client.find_element_by_css_selector('button.done').click()
        time.sleep(self.waitTime)
        self.debug("Clicking publish")
        self.client.find_element_by_css_selector('.draft_warning button[value="Continue"]').click()
        time.sleep(10)
コード例 #5
0
def GenerateSuperHeroName():
    SuperHeroName = spintax.parse(r"{The |}{Super|Scarlet|Commander|Hydro|Captain|Fantastic|Colossal|Nighthawk|Wild} {Mountain|Hawk|Flame|Claw|Machine|Watchman}")
    return SuperHeroName[0]
コード例 #6
0
import spintax
import super_hero_name_generator
# Generate Super hero name
SuperHeroName = super_hero_name_generator.GenerateSuperHeroName()
# Generate greeting
SuperHeroText = r"""
{Hello|Hi|Hey}{,|} I{'| a}m \{0\}{,|!|!!!}
I {{come|am} {here|on this earth}|{came|travelled} {here|to this place}} to {protect|save} {humanity|the world|humans|civilization} {and {destroy|kill|eradicate|remove}|by {destroy|kill|eradicat|remov}ing} all {evil|badness|hate}.
"""
print(spintax.parse(SuperHeroText)[0].format(SuperHeroName))
# As the { and } were escaped this allowed us to use .format() to insert the name
コード例 #7
0
def GenerateSuperHeroName():
    SuperHeroName = spintax.parse(
        r"{The |}{Super|Scarlet|Commander|Hydro|Captain|Fantastic|Colossal|Nighthawk|Wild} {Mountain|Hawk|Flame|Claw|Machine|Watchman}"
    )
    return SuperHeroName[0]
コード例 #8
0
    def createPost(self):
        if not self.isLoggedIn:
            return 0

        self.debug("Navigating to post page")
        self.client.get("https://vancouver.craigslist.ca/search/bnc/lbs")
        self.client.find_element_by_css_selector(".post").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='so']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='82']").click()
        time.sleep(self.waitTime)
        self.client.find_element_by_css_selector("input[value='" +
                                                 str(self.location) +
                                                 "']").click()
        time.sleep(self.waitTime)

        self.debug("Trying to fill in email")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(
                self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")
        try:
            self.client.find_element_by_css_selector('#FromEMail').send_keys(
                self.loginEmail)
        except NoSuchElementException:
            self.debug("Not avaliable")

        self.debug("Checking 'Okay to contact by phone'")
        self.client.find_element_by_css_selector("#contact_phone_ok").click()
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact by text'")
        self.client.find_element_by_css_selector("#contact_text_ok").click()
        time.sleep(self.waitTime)
        self.debug("Filling in contact phone number")
        self.client.find_element_by_css_selector("#contact_phone").send_keys(
            self.contactNumber)
        time.sleep(self.waitTime)
        self.debug("Filling in contact name")
        self.client.find_element_by_css_selector("#contact_name").send_keys(
            self.contactName)
        time.sleep(self.waitTime)
        self.debug("Filling in post title")
        self.client.find_element_by_css_selector("#PostingTitle").send_keys(
            spintax.parse(self.postTitle))
        time.sleep(self.waitTime)
        self.debug("Filling in zip code")
        self.client.find_element_by_css_selector("#postal_code").send_keys(
            self.postCode)
        time.sleep(self.waitTime)

        self.debug("Getting post content")
        f = open(self.postContent, "rb")
        content = f.read().decode()
        f.close()

        self.debug("Spinning content")
        spinContent = spintax.parse(content)

        self.debug("Filling in post content")
        self.client.find_element_by_css_selector("#PostingBody").send_keys(
            spinContent)
        time.sleep(self.waitTime)
        self.debug("Checking 'Okay to contact for other offers'")
        self.client.find_element_by_css_selector("#oc").click()
        time.sleep(self.waitTime)
        self.debug("Unchecking 'Want a map' if checked")
        try:
            self.client.find_element_by_css_selector("#wantamap:checked")
        except NoSuchElementException:
            self.debug("Not checked")
        finally:
            self.client.find_element_by_css_selector(
                "#wantamap:checked").click()
        time.sleep(self.waitTime)

        self.debug("Checking no replies to this email")
        self.client.find_element_by_css_selector("input#A").click()

        self.debug("Clicking continue")
        self.client.find_element_by_css_selector(
            'button[value="Continue"]').click()

        time.sleep(self.waitTime)

        # Upload Image/s
        if "editimage" in self.client.current_url:
            self.debug("Uploading image")
            self.client.find_element_by_css_selector('a#classic').click()
            time.sleep(2)
            self.client.find_element_by_css_selector(
                "input[type=\"file\"]").send_keys(os.getcwd() + "/truck.jpg")
            time.sleep(5)
            self.client.find_element_by_css_selector('button.done').click()

        time.sleep(self.waitTime)
        self.debug("Clicking publish")

        self.client.find_element_by_css_selector(
            '.draft_warning button[value="Continue"]').click()
        time.sleep(5)