MissingSchema:无效 URL 'h':未提供架构。也许你的意思是 http://h?

MissingSchema: Invalid URL 'h': No schema supplied. Perhaps you meant http://h?

我一直在尝试从 google 中抓取不同公司名称的地址和 Phone 号码,当我给出 URL 时,我的代码工作正常,它会获取所需的信息。但是当我尝试循环时出现以下错误。

 MissingSchema: Invalid URL 'h': No schema supplied. Perhaps you meant http://h?

但同样的 URL 工作正常,如下所示!

url = 'https://www.google.com/search?q=goinggourmet'
response = requests.get(url, {"User-Agent": ua.random})
print(Address)

这是在循环时引发错误的代码

bus_name = ['go', 'Copper']
for names in bus:
    html= urllib.parse.quote_plus(names)
    for url in google_urls:
        response = requests.get(url, {"User-Agent": ua.random})

因为您在迭代之前将 google_urls 创建为字符串,所以 for 循环会迭代其中的字符

>>> for char in "http":
...   print(char)
...
h
t
t
p