I am trying to build a bot that will scrap the purchase history of purchased domains. So far I was able to extract the domain from the csv file and store them into a list (PS: there are 10k domains). The problem accures when I am trying to scrap the website with them. I have tried doing this with two domains and it works perfectly. Does anyone know what error is this and how I can fix it? Thank you very much in advance.
my code:
datafile = open('/Users/.../Documents/Domains.csv', 'r')
myreader = csv.reader(datafile, delimiter=";",)
domains = []
for row in myreader:
domains.append(row[1])
del domains[0]
print("The Domains have been stored into a list")
nmb_sells_record = 0
def result_catcher(domains,queue):
template_url = "https://namebio.com/{}".format(domain)
get = requests.get(template_url)
results = get.text
last_sold = results[results.index("last sold for ")+15:results.index(" on 2")].replace(",","")
last_sold = int(last_sold)
if not "No historical sales found." in results:
sold_history = results[results.index("<span class=\"label label-success\">"):results.index(" USD</span> on <span class=\"label")]
queue.put(results)
#domains = ["chosen.com","koalas.com"]
queues = {}
nmb=0
for x in range(len(domains)):
new_queue = "queue{}".format(nmb)
queues[new_queue] = queue.Queue()
nmb += 1
count = 0
for domain in domains:
for queue in queues:
t = threading.Thread(target=result_catcher, args=(domain,queues[queue]))
t.start()
print("The Requests were all sent, now they are beeing analysed")
for queue in queues:
response_domain = queues[queue].get()
nmb_sells_record = response_domain.count("for $") + response_domain.count("USD")
print("The Bot has recorded {} domain sells".format(nmb_sells_record))
The output of my code:
Exception in thread Thread-345:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 284, in connect
conn = self._new_conn()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x115a55a20>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known