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



我一直试图从谷歌刮地址和电话号码为不同的企业名称,我的代码工作正常,当我给一个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 value in "http":  # iterates over characters
...     print(value)
...
h
t
t
p
>>> for value in ["http"]:  # iterates over a list with 1 member
...     print(value)
...
http

相关内容

最新更新