-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspraynpray.py
91 lines (71 loc) · 2.98 KB
/
spraynpray.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: utf-8 -*-
import json, urllib, webbrowser
print("\n")
print("Loading...\n")
# MacOS
chrome_path = 'open -a /Applications/Google\ Chrome.app %s'
# Windows
# chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
# Linux
# chrome_path = '/usr/bin/google-chrome %s'
batch_num = 5
action_urls = []
api_base = "http://api.indeed.com/ads/apisearch?publisher="
standard_q = "&limit=25&radius=25&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2&format=json"
"""Go to indeed and find a search query you'd like to sift through"""
def set_batch():
print("\nHow many auto-apply jobs would you like to open at once?")
while True:
batch_num = input("Enter Tab Open Count: ")
try:
val = int(batch_num)
if val > 0 and val < 26:
break
else:
print("pick a number greater than 0 and less than 26")
except ValueError:
print("Amount must be a number, try again")
return val
batch_num = set_batch()
print("\nPaste the search URL (e.g. https://www.indeed.com/jobs?q=sql&l=19009) you want to use")
search_query = input("Paste url here: ")
print("\nNow we need a publisher API key below")
secret_key = input("Enter API key here:")
q = search_query.split('?q=',1)[1].replace('#','')
complete_url = api_base + secret_key + "&q=" + q + standard_q
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
with urllib.request.urlopen(complete_url) as q_result:
print("\nRunning query for "+ q + "...\n")
q_data = json.loads(q_result.read().decode())
result_count = q_data['totalResults']
number_pages = int(round(result_count / 25, 0) + 1)
"""go to all pages and search through raw results"""
for i in range(1, number_pages):
page = (i*25)-25
page_url = api_base + secret_key + "&q=" + q + standard_q + "&start=" + str(page)
print("searching results from page "+ str(i) + "...\n")
with urllib.request.urlopen(page_url) as p_result:
page_data = json.loads(p_result.read().decode())
page_results = page_data["results"]
if len(page_results) > 0:
for result in page_results:
# filter out those with no autoapply
if result["indeedApply"] is True:
target_url = result["url"]
if target_url not in action_urls:
action_urls.append(target_url)
if len(action_urls) > 0:
blocks = list(chunks(action_urls, batch_num))
block_num = 0;
print(" Opening " + str(batch_num) + " at a time. \n")
for block in blocks:
block_num += 1
print("Press enter to open batch number " + str(block_num))
bla = input()
for block_url in block:
webbrowser.get(chrome_path).open(block_url)
else:
print("No auto apply urls found")