When I run this script, the error message 'wrap_socket' appears
try installing ssl using pip command but every time it crashes
import pickle, pdb, traceback
from pymongo import MongoClient
import urllib2, re
from bs4 import BeautifulSoup
import pprint
import socket, ssl
This is my class
class AvvoQA(object):
def _init_(self):
self.client=MongoClient('localhost',27017)
self.db=self.client.local
self.collection=self.db.awo
this is the database insert code
def ins(self,awo):
client=MongoClient('localhost',27017)
db=client.local
collection=db.awo
collection.insert(awo)
This is the main function.
def awoMain(self):
article_list = []
link = 'https://www.avvo.com/topics/green-cards/advice?question=1'
findFile = urllib2.urlopen(link)
findHtml = findFile.read()
findFile.close()
soup = BeautifulSoup(findHtml, "lxml")
que = soup.findAll('div', attrs={'class' : 'card topic-advice-question-card'})
for div in que:
try:
awo = {}
awo['question'] = div.findAll('a',attrs={'class':'block-link'})['href']
record['desc_link'] = div.find('a')['href']
record = self.getAns(record)
pprint.pprint(awo)
except:
print
print "This articles faces issue "
print traceback.format_exc()
if __name__ == '__main__':
AvvoQA().awoMain()
Error shown
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 803, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 755, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1156, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
AttributeError: 'module' object has no attribute 'wrap_socket'