Python 从文本文件读取多个URL并使用pycurl查找解析结果
我需要得到文本文件中所有URL的结果,如下所示Python 从文本文件读取多个URL并使用pycurl查找解析结果,python,python-3.x,url,pycurl,Python,Python 3.x,Url,Pycurl,我需要得到文本文件中所有URL的结果,如下所示 www.google.com example.com facebook.com 文件中有1000多个URL,我需要通过文件逐个解析URL以测试结果 buf = BytesIO() with open(data.txt) as fi: files = fi.readlines() for web in files: c = pycurl.Curl() c.setopt(c.URL, 'htt
www.google.com
example.com
facebook.com
文件中有1000多个URL,我需要通过文件逐个解析URL以测试结果
buf = BytesIO()
with open(data.txt) as fi:
files = fi.readlines()
for web in files:
c = pycurl.Curl()
c.setopt(c.URL, 'https://'+ web )
c.setopt(c.SSL_VERIFYPEER, 0)
c.setopt(c.SSL_VERIFYHOST, 0)
c.setopt(c.TIMEOUT, 3)
c.setopt(c.WRITEDATA, buf)
c.setopt(c.RESOLVE, [ web + ':443:203.210.7.46'])
c.perform()
它给出了一个回溯c.perform()pycurl.error:(3',)
但是如果我直接把一个url放在c.url中,它就可以很好地工作。有人能帮我一下吗。谢谢您从
readlines
获得的行以换行符\n
结尾,因此循环的第一次迭代将c.URL
设置为:
'https://www.google.com\n'
pycurl告诉您这是意外的:错误3是,“URL格式不正确”
调用web.strip()