def get_leads_to_filter(): r = requests.post( urllib.parse.urljoin(util.get_root_url(), 'api/get_leads_to_filter')) print(r.status_code) if r.status_code != 200: raise AssertionError('leads to filter cannot be obtained') return r.json()
def send_user_with_cv(current_cv_path, user): cv_path = poll_for_last_download(current_cv_path) if cv_path is not None: with open(cv_path, 'rb') as cv: response = requests.post(util.get_root_url() + '/api/v1/register', data=user, files={'curriculum_url': cv}) print('user cv_path: ' + cv_path) return response else: return requests.post(util.get_root_url() + '/api/v1/register', data=user)
def get_campaigns(): """ List of dictionaries with campaigns :return: """ response = requests.get(util.get_root_url() + '/api/v1/get_campaigns') return [ c for c in json.loads(response.json()) if c['fields']['title_es'] is not None ]
def save_leads_in_api(results): results.fillna('', inplace=True) r = requests.post( urllib.parse.urljoin(util.get_root_url(), 'api/save_leads'), { 'names': results['name'], 'facebook_urls': results.index.values, 'phones': results['phone'], 'emails': results['email'] }) print(r.status_code) if r.status_code != 200: raise AssertionError("leads couldn't be saved")
def run(): phone_leads = util.read_phone_excel_leads() phone_leads = fulgencio.filter_results(phone_leads) if not DEBUG: r = requests.post(urllib.parse.urljoin(util.get_root_url(), 'api/add_messages'), data={ 'names': phone_leads['name'], 'messages': phone_leads['message'], 'phones': phone_leads['phone'], 'emails': phone_leads['email'], 'facebook_urls': phone_leads.index.values }) print(r.status_code, r.reason) fulgencio.save_leads_in_api(phone_leads)
def scrap_candidate(campaigns, cities, browser, sent_candidates): campaign = get_campaign_with_id( campaigns, BeautifulSoup(browser.page_source, 'html.parser')) user = scrap_profile(html_source=browser.page_source, cities=cities, campaign=campaign) if user.get(EMAIL) and candidate_not_sent(sent_candidates, user, campaign): current_cv_path = get_last_download_path() # TODO: if found more formats, please add: pdf_icon = get_icon(browser, 'pdf_hdv') doc_icon = get_icon(browser, 'doc_hdv') if pdf_icon: pdf_icon.click() response = send_user_with_cv(current_cv_path, user) elif doc_icon: doc_icon.click() response = send_user_with_cv(current_cv_path, user) else: response = requests.post(util.get_root_url() + '/api/v1/register', data=user) print('user data:') print(user) print('sent user with response: ' + str(response.status_code)) return sent_candidates.append([{ EMAIL: user[EMAIL], CAMPAIGN_ID: user.get(CAMPAIGN_ID), KEY: get_key(user, campaign) }]) else: return sent_candidates
def is_safe_url(url): root_url = get_root_url(url) url = SAFE_API_URL % (SAFE_API_KEY, root_url) req = requests.get(url) return req.text == ''
def is_safe_url(url): root_url = get_root_url(url) url = SAFE_API_URL %(SAFE_API_KEY, root_url) req = requests.get(url) return req.text == ''
def get_cities(): response = requests.get(util.get_root_url() + '/api/v1/get_cities') return json.loads(response.json())