requests.exceptions.MissingSchema:无效的URL's':未提供架构。也许你指的是http://s?

2024-04-24 08:10:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在子域查克上工作,测试url的文件和打印工作,查克一个人的第一个我使用的urllib没有做这项工作 看到我用了requets,一切都会成功 我的要求有误 url示例:

https://et7-1.fab5-2-gdc.bf1.yahoo.com

我的代码

import argparse, requests
from requests.exceptions import MissingSchema
p = argparse.ArgumentParser()
p.add_argument("-f", "--file",required=True, help="subdomain file" )
args = p.parse_args()
def get_url_nofollow(url):
    req = requests.get(url, timeout=5)
    respnse = req.status_code()
    if respnse == 200:
        return respnse
    

def main():
    url = {}
    for line in args.file:
        line=line.strip()
        if line not in url:
            print('chaching url %d', url)
            url[line] = {'code': get_url_nofollow(line), 'count': 1}
            print("++ %s\n" % str(urls[line]))
        else:
            urls[line]['count'] = urls[line]['count'] + 1
if __name__ == "__main__":
    main()


谢谢


Tags: importurlgetifmaindefcountline