I want to email the script to any object in the new properties list. Each object list like so:
newProperties [0] = { "marketing_package_url": "http://www.capitalpacific.com/inquiry/TrailsEndMarketplaceExecSummary.pdf", "Location": "Goa city, or", "title": "trails end Market", "Contact": "mailto: mhorwitz@capitalpacific.com"} \ newProperties [1] = { "marketing_package_url": "http: // cp. capitalpacific .com / properties / yukon-village-yukonOK.pdf "," location ":" yukon, okay "," title ":" yukon village "," contact ":" mailto: rsanner@capitalpacific.com "} .. Selenium import webdriver import import import import import import cs import json driver = web driver. Firefox () # Capitol Pacific website # Commerexle
/ full script
Real Estate #open text file containing the property title, which we already know about #list q, unique marketing URLs that we know about old properties = [] P = Rie Compel (R 'https ?: \ / \ [^ "] +' with Re.IGNORECASE | re.MULTILINE) (open (" properties F: in the line f: q = re.findall (p, line) oldProperties.extend (q) #search driver.get for new listing ("http: // cp .capitalpacific.com / properties ") # Current List page to enter the list newProperties = [] property driver.find_elements_by_css_selector ( 'table.property div.property'): title = property.find_element_by_css_selector ( 'div.title h2') position = property.find_element_by_css_selector ( ' div.title h4 ') marketing_package = property Kfind_element_by_partial_link_text (' marketing package ') contact_email = property.find_element_by_partial_link_text newProperties.append ({' title '(' com. '): title.text,' location ': location.text,' marketing_package_url ': marketing_package.get_attribute ( "href"),' Contact ': contact_email.get_attribute ( "href")}) driver.close () # that #marketing URLS X old properties refers to cross Th Search for: For items in new properties: if (item ['Marketing Ng_package_url'] == x: newProperties.remove (item) #properties now only have new properties - open them in the file ('properties.txt' , 'W'): For items in new properties: Jason .dump (item, outfile) # If no new properties are found, then skip #else, end email properties # New If the property is not found, then delete script #else, email properties if len (newProperties) == 0: sys.exit () else: fromaddr = 'osxxxxxt @ gm ail.com 'toaddrs = [' osfsfsar@onid.oregonstate.edu '] username =' xxxx@gmail.com 'password =' 0fdrfdf 'server = smtplib.SMTP (' smtp.gmail.com: 587 ') server. Server.login (user name, password) for starttls () newProperties items: msg = str (items) #PROBLEM server here. Sendmail (fromaddr, toaddrs, msg) server.quit ()
The problem is currently the email sent is empty, I used to add new entries on the page, but it appears that the problem of creating a word in a string and sending it Is happening Does anyone know how I can fix this?