0

I am trying to use beautiful soup to extract data from a link...currently its failing authentication like below..how do I authenticate the link,I know the server that should be logged-in..where to provide the server path and how to validate the link?

from bs4 import BeautifulSoup as bs
import argparse
import urllib
import urllib2
import getpass
import re
import requests

def update (url):
    print url
    r = requests.get(url)
    html = r.text
    soup = bs(html)
def main ():
    #For logging
    print "test"
    parser = argparse.ArgumentParser(description='This is the update.py script created by test')
    parser.add_argument('-u','--url',action='store',dest='url',default=None,help='<Required> url link',required=True)
    results = parser.parse_args()# collect cmd line args
    url = results.url
    #print url
    update(url)
if __name__ == '__main__':
    main()

Error:-

Traceback (most recent call last):
  File "announce_update2.py", line 24, in <module>
    main()
  File "announce_update2.py", line 22, in main
    update(url)
  File "announce_update2.py", line 11, in update
    r = requests.get(url)
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\api.py", line 55, in get
    return request('get', url, **kwargs)
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\sessions.py", line 289, in request
    history = [r for r in gen] if allow_redirects else []
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\sessions.py", line 133, in resolve_redirects
    proxies=proxies
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests-1.1.0-py2.7.egg\requests\adapters.py", line 213, in send
    raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
4

0 回答 0