Exemplo n.º 1
0
        sqft = listing.sqft if listing.sqft else "could not find sqft count"
        price = listing.price if listing.price else "could not find price"
        address = listing.address if listing.address else "could not find location"
        mailto = listing.mailto if listing.mailto else "could not find email address"
        title = listing.title.replace(",", ".")
        print ",".join([title, listing.href, price, listing.date, address, bdrm, sqft, mailto, listing.query])

if __name__ == '__main__':
    parser = argparse.ArgumentParser("Parse craigslist and upload to a google spreadsheet",
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("--csv", help="Output as csv rather than uploading to a google "
            "spreadsheet", action="store_true")
    parser.add_argument("--sheet-name", help="Spreadsheet name", default="Snatched Apartments")
    parser.add_argument("--craigslist-url", help="Craigslist URL for your location",
            default="http://washingtondc.craigslist.org")
    parser.add_argument("--keywords", help="Comma separated list of search keywords",
            default="friendship heights,tenleytown")
    parser.add_argument("--max-price", help="Maximum monthly rent", default=1000, type=int)
    parser.add_argument("--min-bedrooms", help="Minimum number of bedrooms", default=1, type=int)
    parser.add_argument("--min-square-feet", help="Minimum square feet", default=800, type=int)
    parser.add_argument("--username", help="Google username.  Don't set this or --password to use oauth.")
    parser.add_argument("--password", help="Google password.  Don't set this or --username to use oauth.")
    args = parser.parse_args()
    listings = scrapers.scrape_craigslist(root_url=args.craigslist_url, keywords=args.keywords.split(","),
            max_price=args.max_price, min_bedrooms=args.min_bedrooms,
            min_square_feet=args.min_square_feet)
    if args.csv:
        csv_listings(listings)
    else:
        post_listings(listings, args.sheet_name, args.username, args.password)
Exemplo n.º 2
0
            for job in jobs[region]:
                message += job + ' - <a href="' + jobs[region][job] + '">Link</a><br>'
    return message

msg = MIMEMultipart()
msg['Subject'] = 'Job Report for {} {}'.format(datetime.now().strftime('%A, %B'), datetime.now().day)
msg['From'] = user
msg['To'] = user

html = """\
  <html>
    <head></head>
    <body>
      <p>"""

craigs_jobs = scrapers.scrape_craigslist()
dice_jobs = scrapers.scrape_dice()
cybercoder_jobs = scrapers.scrape_cybercoders()
indeed_jobs = scrapers.scrape_indeed()

updated_html = add_jobs_to_message(craigs_jobs, html)
updated_html = add_jobs_to_message(dice_jobs, updated_html)
updated_html = add_jobs_to_message(cybercoder_jobs, updated_html)
updated_html = add_jobs_to_message(indeed_jobs, updated_html)


updated_html += """\
      </p>
    </body>
  </html>"""