diff --git a/craigslist_shellnium_example.sh b/craigslist_shellnium_example.sh new file mode 100755 index 0000000..f8f7ab4 --- /dev/null +++ b/craigslist_shellnium_example.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash +# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) +# https://www.youtube.com/user/gotbletu +# DESC: my unfinish example shellnium script for craigslist +# DEMO: https://youtu.be/Q10dcPjmRTI +# DEPEND: jq chromium (or chrome) +# shellnium (https://github.com/Rasukarusan/shellnium) + +# start chromedriver +chromedriver & +sleep 1 + +source ./lib/selenium.sh + +ITEM_TITLE="Leaf Village" +ITEM_PRICE="10" +ITEM_CITY="North Hollywood" +ITEM_POSTAL="91601" +ITEM_DESCRIPTION="Village Hidden in the Leaf" +ITEM_CONTACTEMAIL="tobi@akatsuki.com" +ITEM_CONTACTNUM="818-333-4444" +ITEM_CONTACTNAME="Tobi" + +ITEM_STREET="hatteras" +ITEM_CROSSSTREET="tujunga" + +main() { + + # 1. Open the apage. + navigate_to 'https://post.craigslist.org/c/lax' + + # Click on radio "san fernado valley" + # + local radioclick_location=($(find_elements 'name' 'n')) + click ${radioclick_location[1]} + + + # 2. Click on radio "for sale by owner" + local radioclick_sale=($(find_elements 'name' 'id')) + click ${radioclick_sale[5]} + + # 3. Click on radio "video gaming by owner" + local radioclick_videogame=($(find_elements 'name' 'id')) + click ${radioclick_videogame[43]} + + # 4. Fill in Ad listing + + # Post Title + # + local AD_TITLE=$(find_element 'name' 'PostingTitle') + send_keys $AD_TITLE "$ITEM_TITLE" + + # Price + # + local AD_PRICE=$(find_element 'name' 'price') + send_keys $AD_PRICE "$ITEM_PRICE" + + # City or neighborhood + # + local AD_CITY=$(find_element 'name' 'geographic_area') + send_keys $AD_CITY "$ITEM_CITY" + + # Postal Code/Zip code + # + local AD_POSTAL=$(find_element 'name' 'postal') + send_keys $AD_POSTAL "$ITEM_POSTAL" + + # Description + # + local AD_DESCRIPTION=$(find_element 'name' 'PostingBody') + send_keys $AD_DESCRIPTION "$ITEM_DESCRIPTION" + + # [checkbox] include "more ads by this user" link + # + local checkbox_moreads=($(find_element 'name' 'see_my_other')) + click ${checkbox_moreads} + + # [checkbox] contact info: phone/text options enable + # + local checkbox_phone=($(find_element 'name' 'show_phone_ok')) + click ${checkbox_phone} + + # [checkbox] text/SMS OK + # + local checkbox_texting=($(find_element 'name' 'contact_text_ok')) + click ${checkbox_texting} + + # Contact Email + # + local AD_CONTACTEMAIL=$(find_element 'name' 'FromEMail') + send_keys $AD_CONTACTEMAIL "$ITEM_CONTACTEMAIL" + + # Contact Number: Phone Number/Texting Number + # + local AD_CONTACTNUM=$(find_element 'name' 'contact_phone') + send_keys $AD_CONTACTNUM "$ITEM_CONTACTNUM" + + # Contact Name + # + local AD_CONTACTNAME=$(find_element 'name' 'contact_name') + send_keys $AD_CONTACTNAME "$ITEM_CONTACTNAME" + + # Click Continue Button + # + local button_continue=($(find_element 'name' 'go')) + click ${button_continue} + + # 5. Map Page + # Street + # + local AD_STREET=$(find_element 'name' 'xstreet0') + send_keys $AD_STREET "$ITEM_STREET" + + # Cross Street + # + local AD_CROSSSTREET=$(find_element 'name' 'xstreet1') + send_keys $AD_CROSSSTREET "$ITEM_CROSSSTREET" + + # City (use same variables as last page) + # + local AD_CITY=$(find_element 'name' 'city') + send_keys $AD_CITY "$ITEM_CITY" + + # Postal (use same variables as last page) + # + local AD_POSTAL=$(find_element 'name' 'POSTAL') + send_keys $AD_POSTAL "$ITEM_POSTAL" + + # Click Find Button + # + local button_find=$(find_element 'id' 'search_button') + click ${button_find} + + # Click Continue Button (class name with space just ignore the anything after the 1st word) + # + local button_continue=($(find_element 'class name' 'continue')) + click ${button_continue} + + # 6. Add Images: Max 24 images + # Add Images Button + # done with images + local button_donewithimages=($(find_element 'class name' 'done')) + click ${button_donewithimages} + +} +main + +# stop chromedriver +killall chromedriver