Q: No connection adapters were found? I am trying to open scrape all urls in a csv file. Then open the csv file and read each url opening each url to search and grab the Source info, Author, and License info. Then need to follow the respected gitlink to see if there is a license file or not. If there is a license file download and save it to csv file.
I have the below code in place however am receiving the following error upon reading the first url in my file:
No connection adapters were found for "['https://tools.kali.org/information-gathering/ace-voip']"
Actual Error:
File "ommitted", line 742, in get_adapter
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
InvalidSchema: No connection adapters were found for "['https://tools.kali.org/information-gathering/ace-voip']"
I think this is happening because there is the added "[' in front of my url however, this doesnt exist in my file of listed urls.
I am new to python and appreciate any and all help on this.
import urllib.request, urllib.parse, urllib.error
import ssl
import zlib
from bs4 import BeautifulSoup
import csv
from urllib.request import urlopen
import urllib
import urllib.parse
import requests

#Testing ssl and reading url
#urllib.request.urlopen('https://google.com').read()


ctx = ssl._create_default_https_context()
# Establish chrome driver and go to report site URL
ctx.check_hostname = False  
ctx.verify_mode = ssl.CERT_NONE

url = 'https://tools.kali.org/tools-listing'


html = urllib.request.urlopen(url, context=ctx)#.read().decode('utf-8')

de_data=zlib.decompress(html.read(), 16+zlib.MAX_WBITS)

print(de_data)

soup = BeautifulSoup(de_data, 'lxml')



data = []
for url in soup.find_all('a', href=True, text=True):
    print(url['href'])
    data.append(url['href'])
      
     
print(data)

 
####New Replacement for above that works removing spaces########
with open('kalitools.csv', 'w') as file:
    for url in data:
        file.write(str(url) + 'n')

# loading csv file with URLS and parsing each
######TESTING Reading URLS########

with open('E:/KaliScrape/kalitools.txt', 'r') as f_urls, open('ommitted/output.txt', 'w', newline='') as f_output:
    csv_urls = csv.reader(f_urls)
    csv_output = csv.writer(f_output)
    csv_output.writerow(['Source', 'Author', 'License'])
    
    
    print(csv_urls)
    for line in csv_urls:
      r = requests.get(line)#.text
      soup = BeautifulSoup(r, 'lxml')
    
    #r = requests.get(line[0], verify=False)#.text
    #for line in csv_urls:
     # line = 'https://' + line if 'https' not in line else line
     # source = urlopen(line).read()
    
    
      src = soup.find('li')
      print('Source:', src.text)
    
    
      auth = soup.find('li')
      print('Author:', auth.text)


      lic = soup.find('li')
      print('License:', lic.text)


    csv_output.writerow([src.text, auth.text, lic.text])


A: So, the problem is you are getting a list, and you just need to pick the list element at the zero index,
for line in csv_urls:
      r = requests.get(line[0])#.text

