2017-10-03 4 views
0

J'ai un fichier texte links.txt. Il avait 100 URLs avec http et https. Je veux ouvrir ces URL et rechercher des chaînes spécifiques dans chaque site. C'est ce que j'ai écrit jusqu'ici. Je reçois erreur SSL:accéder à plusieurs URL et lire le contenu du site en utilisant python

with open ("links.txt") as txt_file:   
    for line in txt_file.readlines():    
      print line 
      html =urllib2.urlopen(line).read() 

      print html 

Répondre

0

la documentation De urlopen:

The optional cafile and capath parameters specify a set of trusted CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations().