Python requests.exceptions.MissingSchema:无效URL''&引用;

Python requests.exceptions.MissingSchema:无效URL''&引用;,python,python-3.x,for-loop,request,Python,Python 3.x,For Loop,Request,获取丢失的架构错误,即使链接中有https: 我正在尝试使用Python清理多个wiki页面,我在excel中有一个wiki URL列表 并创建了一个Python类,用于抓取Wiki页面并在for循环中运行它。在没有for循环的情况下运行代码时,我可以得到输出,但是当我在for循环中包含以下代码时,我会得到缺少的模式 重新导入 从bs4导入BeautifulSoup 导入请求 导入xlrd wb=xlrd.open_工作簿('list.xls') 工作表=工作表。工作表按索引(0) 班级维基:

获取丢失的架构错误,即使链接中有https:

我正在尝试使用Python清理多个wiki页面,我在excel中有一个wiki URL列表

并创建了一个Python类,用于抓取Wiki页面并在for循环中运行它。在没有for循环的情况下运行代码时,我可以得到输出,但是当我在for循环中包含以下代码时,我会得到缺少的模式

重新导入
从bs4导入BeautifulSoup
导入请求
导入xlrd
wb=xlrd.open_工作簿('list.xls')
工作表=工作表。工作表按索引(0)
班级维基:
定义初始化(self,url):
#self.name=名称
self.url=url
cont=requests.get(self.url,超时=5)
soup=BeautifulSoup(cont.content,“html.parser”)
def urlcont(自身):
cont=requests.get(self.url,超时=5)
soup=BeautifulSoup(cont.content,“html.parser”)
打印(soup.prettify())
def头(自身):
cont=requests.get(self.url,超时=5)
soup=BeautifulSoup(cont.content,“html.parser”)
title=soup.find(class='firstHeading').i.text
返回标题
对于范围内的i(图纸编号):
url=工作表。单元格_值(i,2)
打印(url)
数据=维基(url)
head=data.head()
打印(头)
运行此代码后出错

回溯(最近一次呼叫最后一次):
文件“D:\PYTHON\1click\final\alex.py”,第177行,在
movie=wikimovie(movieurl)
文件“D:\PYTHON\1click\final\alex.py”,第69行,在\uuu init中__
cont=requests.get(self.url,超时=5)
文件“C:\Users\acer\AppData\Local\Programs\Python38-32\lib\site packages\requests\api.py”,第75行,在get中
返回请求('get',url,params=params,**kwargs)
文件“C:\Users\acer\AppData\Local\Programs\Python\Python38-32\lib\site packages\requests\api.py”,请求中第60行
return session.request(method=method,url=url,**kwargs)
文件“C:\Users\acer\AppData\Local\Programs\Python\Python38-32\lib\site packages\requests\sessions.py”,请求中第519行
准备=自我准备请求(req)
文件“C:\Users\acer\AppData\Local\Programs\Python38-32\lib\site packages\requests\sessions.py”,第452行,在prepare\u请求中
p、 预备(
文件“C:\Users\acer\AppData\Local\Programs\Python38-32\lib\site packages\requests\models.py”,第313行,在prepare中
self.prepare_url(url,参数)
文件“C:\Users\acer\AppData\Local\Programs\Python 38-32\lib\site packages\requests\models.py”,第387行,位于prepare\u url中
raise MissingSchema(错误)
requests.exceptions.MissingSchema:无效URL“”:未提供架构。您的意思可能是http://?
删除For循环时的输出

https://en.wikipedia.org/wiki/######
######
用于打印所有url(带有for循环)而不调用类的输出

https://en.wikipedia.org/wiki/######
https://en.wikipedia.org/wiki/######
https://en.wikipedia.org/wiki/######

当for循环被忽略并用此行“url=sheet.cell_value(I,2)”中的任何其他随机值替换var I时,我可以得到的输出。

您确定这些都是工作表中的url,并且工作表中没有空行吗?您也可以尝试
打印(repr([sheet.cell_value(I,2)for I in range(sheet.nrows)])
用于调试。谢谢@CristianCiupitu您在那里第一排是空的