Python Selenium code to scrape Craiglist

This code will post ads on you behalf. You need to make changes in variables to be modified section.

from __future__ import print_functionfrom selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.keys import Keysimport time
#Variables to be modifiedemail="Your Email"psswd="You Password"title="Title of the post"location="Atlanta"postal_code= "30303"post_body = "Content Goes Here"
driver = webdriver.Chrome('C:\Python27\chromedriver')driver.get("https://accounts.craigslist.org/login")
#fill login formtime.sleep(3)element = driver.find_element_by_xpath('//*[@id="inputEmailHandle"]')element.send_keys(email)element = driver.find_element_by_xpath('//*[@id="inputPassword"]')element.send_keys(psswd)element = driver.find_element_by_xpath('/html/body/section/section/div/div[1]/form/div[3]/button')time.sleep(3)element.click()time.sleep(5)
#start postingdriver.get("https://atlanta.craigslist.org/")ele_post = driver.find_element_by_xpath('//*[@id="post"]')ele_post.click()time.sleep(3)radio_service_offered = driver.find_element_by_xpath('/html/body/article/section/form/blockquote/label[10]/input')radio_service_offered.click()radio_financial_services = driver.find_element_by_xpath('/html/body/article/section/form/blockquote/label[9]/input')radio_financial_services.click()raido_cityofatlanta = driver.find_element_by_xpath('/html/body/article/section/form/blockquote/label[1]/input')raido_cityofatlanta.click()radio_mail_relay = driver.find_element_by_xpath('//*[@id="oiab"]/label[1]/input')radio_mail_relay.click()title_s = driver.find_element_by_xpath('//*[@id="PostingTitle"]')title_s.send_keys(title)loc_s = driver.find_element_by_xpath('//*[@id="GeographicArea"]')loc_s.send_keys(location)postal_s = driver.find_element_by_xpath('//*[@id="postal_code"]')postal_s.send_keys(postal_code)body_s = driver.find_element_by_xpath('//*[@id="PostingBody"]')i=0while i < len(post_body):    body_s.send_keys(post_body[i])    i += 1continue_s =driver.find_element_by_xpath('//*[@id="postingForm"]/button')continue_s.click()    time.sleep(3)continue_s1 = driver.find_element_by_xpath('//*[@id="leafletForm"]/button[1]')continue_s1.click()time.sleep(3)done_with_images = driver.find_element_by_xpath('/html/body/article/section/form/button')done_with_images.click()sleep(3)publish_s = driver.find_element_by_xpath('//*[@id="publish_top"]/button')publish_s.click()driver.quit() 

Comments

  1. No Deposit Bonus Codes December 2021 - Keep What You Win
    No 에볼루션 바카라 deposit bonus codes have been around for a long time. These 리드 벳 include the best no deposit bonus codes available. Best casinos w88 dashboard to play with a 바카라양방 No Deposit bet365 우회 Bonus

    ReplyDelete

Post a Comment

Popular posts from this blog

Vivo Y51 themes download itz

Free games for 512 MB RAM Android mobile

m3u8 crossdomain access denied