
GITHUBBBBBBBBBBBB
Posted 24 October 2019 - 06:52 PM
Posted 24 October 2019 - 07:14 PM
Posted 24 October 2019 - 09:09 PM
Posted 24 October 2019 - 09:16 PM
Posted 24 October 2019 - 09:17 PM
Posted 24 October 2019 - 09:31 PM
Posted 25 October 2019 - 02:35 AM
lolwtfdemon, on 25 October 2019 - 12:31 AM, said:
#!/usr/bin/python3 import requests from bs4 import BeautifulSoup as BS import os import smtplib import pandas as pd import re from email.mime.text import MIMEText def find_cars_data(search, max_price, make, max_results): headers = {'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X)'} search_params = {'sort': 'rel', 'min_price': '50', 'max_price': max_price, 'query': make, 'auto_transmission': '1', 'srchType': 'T'} r = requests.get(search, params=search_params, headers=headers) s = BS(r.content, 'html.parser') # c = s.prettify for i, a in enumerate(s.find_all('p', {'class': 'result-info'})): price = a.find('span', {'class': 'result-price'}).text title = a.find('a', {'class': 'result-title'}).text link = a.find('a', attrs={'href': re.compile("^https://")}) yield (price, title, link.get('href')) if not i < max_results - 1: break def data_to_pandas(data_gen): df = {'Car': [], 'Price': [], 'Link': []} for (price, title, link) in data_gen: df['Car'].append(title) df['Price'].append(price) df['Link'].append(link) pd.set_option('display.max_colwidth', -1) cars = pd.DataFrame(df) return(cars.to_html()) def send_gmail(gmail_user, gmail_password, message): try: server = smtplib.SMTP_SSL('smtp.gmail.com', 465) server.ehlo() server.login(gmail_user, gmail_password) # see below server.sendmail(gmail_user, gmail_user, msg=message) except e: # include the error, consider a linter print(e, 'Whoops....') # if you fail out to the except, you shouldn't be trying this here # server.sendmail(gmail_user, gmail_user, msg=message) def main(): url = 'https://annarbor.craigslist.org/' gmail_user, gmail_password = '[email protected]', 'xxxxxxxxxxxxxxx' max_price, make, max_results = '20000', 'Volkswagen', 20 html = data_to_pandas(find_cars_data(url + 'search/sss', max_price, make, max_results)) msg = MIMEText(html, 'html') print(msg.as_string()) # send_gmail(gmail_user, gmail_password, msg.as_string()) main()
Posted 25 October 2019 - 07:45 AM
Posted 25 October 2019 - 06:34 PM
baavgai, on 25 October 2019 - 02:35 AM, said:
lolwtfdemon, on 25 October 2019 - 12:31 AM, said:
#!/usr/bin/python3 import requests from bs4 import BeautifulSoup as BS import os import smtplib import pandas as pd import re from email.mime.text import MIMEText def find_cars_data(search, max_price, make, max_results): headers = {'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X)'} search_params = {'sort': 'rel', 'min_price': '50', 'max_price': max_price, 'query': make, 'auto_transmission': '1', 'srchType': 'T'} r = requests.get(search, params=search_params, headers=headers) s = BS(r.content, 'html.parser') # c = s.prettify for i, a in enumerate(s.find_all('p', {'class': 'result-info'})): price = a.find('span', {'class': 'result-price'}).text title = a.find('a', {'class': 'result-title'}).text link = a.find('a', attrs={'href': re.compile("^https://")}) yield (price, title, link.get('href')) if not i < max_results - 1: break def data_to_pandas(data_gen): df = {'Car': [], 'Price': [], 'Link': []} for (price, title, link) in data_gen: df['Car'].append(title) df['Price'].append(price) df['Link'].append(link) pd.set_option('display.max_colwidth', -1) cars = pd.DataFrame(df) return(cars.to_html()) def send_gmail(gmail_user, gmail_password, message): try: server = smtplib.SMTP_SSL('smtp.gmail.com', 465) server.ehlo() server.login(gmail_user, gmail_password) # see below server.sendmail(gmail_user, gmail_user, msg=message) except e: # include the error, consider a linter print(e, 'Whoops....') # if you fail out to the except, you shouldn't be trying this here # server.sendmail(gmail_user, gmail_user, msg=message) def main(): url = 'https://annarbor.craigslist.org/' gmail_user, gmail_password = '[email protected]', 'xxxxxxxxxxxxxxx' max_price, make, max_results = '20000', 'Volkswagen', 20 html = data_to_pandas(find_cars_data(url + 'search/sss', max_price, make, max_results)) msg = MIMEText(html, 'html') print(msg.as_string()) # send_gmail(gmail_user, gmail_password, msg.as_string()) main()
astonecipher, on 25 October 2019 - 07:45 AM, said:
Posted 25 October 2019 - 06:49 PM
Posted 25 October 2019 - 06:57 PM
astonecipher, on 25 October 2019 - 06:49 PM, said:
Posted 26 October 2019 - 08:12 AM
lolwtfdemon, on 25 October 2019 - 09:34 PM, said: