-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistgen.py
More file actions
156 lines (137 loc) · 4.94 KB
/
Copy pathlistgen.py
File metadata and controls
156 lines (137 loc) · 4.94 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# -------------------------------------------------------------------------------------------------------------------------- #
# .g8888bgd
# .dP M
# ,pP"Ybd ,pW8Wq. dM ;
# 8I 6W Wb MM
# YMMMa. 8M M8 MM.
# L. I8 YA. ,A9 Mb. ,
# M9mmmP; .Ybmd9. ..bmmmd.
# -------------------------------------------------------------------------------------------------------------------------- #
import csv
import os
from splinter import *
import time
from selenium.common.exceptions import NoSuchElementException
LLCS = [line.split(',') for line in open("llclist.txt")]
url = "http://opencorporates.com/companies/us_nc"
fileEmpty = os.stat('output.csv').st_size == 0
def llctoname():
numbers = []
altnumbers = []
True_people_numbers = []
alt_true = []
results = []
owners = []
ownername = []
company_address = []
try:
browser = Browser('chrome')
browser.visit(url)
browser.find_by_xpath('//*[@id="q"]').fill(LLC)
time.sleep(5)
browser.find_by_xpath('/html/body/div[2]/div[2]/div[1]/div[1]/form/div[2]/input[2]').click()
time.sleep(5)
browser.find_by_xpath('//*[@id="results"]').click()
browser.find_by_xpath('//*[@id="companies"]').click()
browser.find_by_xpath('/html/body/div[2]/div[2]/div[1]/div[2]/ul/li/a[2]').click()
time.sleep(5)
ownername = browser.find_by_xpath("/html/body/div[2]/div[2]/div[1]/div[1]/div/dl/dd[9]/ul/li[1]/a").text
substring = ","
if substring in ownername:
newname = ownername.split(",")[1]
newlast = ownername.split(',')[0]
fixed_owner_name = (newname+" "+newlast)
print(fixed_owner_name)
owners.append(fixed_owner_name)
else:
owners.append(ownername)
company_address_get = browser.find_by_xpath("/html/body/div[2]/div[2]/div[1]/div[4]/div[2]/div/div[1]/p").text
zip_code_string = "-"
if zip_code_string in company_address_get:
newaddress = company_address_get.split('-')[0]
print(newaddress)
company_address.append(newaddress)
else:
company_address.append(company_address_get)
print(company_address)
browser.quit()
for comp in company_address:
address = comp
try:
for owner in owners:
browser = Browser('chrome')
browser.visit("http://thatsthem.com/people-search")
browser.find_by_xpath('//*[@id="fullName"]').fill(owner)
time.sleep(5)
browser.find_by_xpath('//*[@id="address"]').fill(address)
time.sleep(5)
browser.find_by_xpath('/html/body/div/main/section[1]/div/form/div/button').click()
time.sleep(5)
Main_number = []
Main_number = browser.find_by_xpath("/html/body/div[1]/main/section[3]/div[2]/div[1]/div/div[3]/div[2]/dl/dd[1]").text
time.sleep(5)
print(Main_number)
alt_numbers = []
alt_numbers = browser.find_by_xpath("/html/body/div[1]/main/section[3]/div[2]/div[1]/div/div[3]/div[2]/dl/dd[2]").text
time.sleep(5)
print(alt_numbers)
numbers.append(Main_number)
altnumbers.append(alt_numbers)
for number in numbers:
person_number = number
for alt in altnumbers:
alternates = alt
results.append({'Company Name': LLC, 'Address': address, 'Name': owner, 'Number': person_number, 'Alt Numbers': alternates})
numbers = []
browser.quit()
except Exception:
pass
browser.quit()
browser = Browser('chrome')
browser.visit("http://www.truepeoplesearch.com/")
browser.find_by_xpath('//*[@id="id-d-n"]').fill(owner)
time.sleep(5)
browser.find_by_xpath('//*[@id="id-d-loc-name"]').fill(address)
time.sleep(5)
browser.find_by_xpath('//*[@id="btnSubmit"]').click()
time.sleep(5)
browser.find_by_xpath('/html/body/div[2]/div/div[2]/div[4]/div[1]/div[2]/a').click()
time.sleep(5)
True_People_Search_numbers = []
True_People_Search_numbers = browser.find_by_xpath('/html/body/div[2]/div/div[2]/div[1]/div[6]/div[2]').text
time.sleep(5)
alt_True_num = []
try:
browser.find_by_xpath('/html/body/div[2]/div/div[2]/div[1]/div[6]/div[2]/div[5]/div/button').click()
alt_True_num = browser.find_by_xpath('//*[@id="morePhones"]').text
alt_true.append(alt_True_num)
except Exception:
pass
print(True_People_Search_numbers)
print(alt_True_num)
True_people_numbers.append(True_People_Search_numbers)
for people_number in True_people_numbers:
Their_phone = people_number
for alt_in in alt_true:
more_numbers = alt_in
results.append({'Company Name': LLC, 'Address': address, 'Name': owner, 'Number': Their_phone, 'Alt Numbers': more_numbers})
True_people_numbers = []
alt_True_num = []
browser.quit()
with open('output.csv', 'a', newline='') as file:
fieldnames = ['Company Name', 'Address', 'Name', 'Number', 'Alt Numbers']
writer = csv.DictWriter(file, fieldnames=fieldnames)
if fileEmpty:
writer.writeheader()
for result in results:
writer.writerow(result)
except Exception:
pass
browser.quit()
if __name__ == '__main__':
while True:
for LLC in LLCS:
try:
llctoname()
except Exception:
pass