Python Can';I don’在需要的时候,我不会制定我的脚本供应计划

Python Can';I don’在需要的时候,我不会制定我的脚本供应计划,python,python-3.x,web-scraping,Python,Python 3.x,Web Scraping,我已经用python创建了一个脚本来使用不同的域名,以便从中解析标题。我当前的尝试引发了以下明显的错误: raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL 'Titanrestoration.Ca': No schema supplied. Perhaps you meant http://Titanrestoration.Ca? 我迄今为止的努力: import requests from bs

我已经用python创建了一个脚本来使用不同的
域名
,以便从中解析
标题
。我当前的尝试引发了以下明显的错误:

raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'Titanrestoration.Ca': No schema supplied. Perhaps you meant http://Titanrestoration.Ca?
我迄今为止的努力:

import requests
from bs4 import BeautifulSoup

links = [
    'Titanrestoration.Ca',
    'Campbellroofing.Ca',
    'Bjmillairebuilders.Ca',
    'Rtroofing.Ca'
    ]

for link in links:
    r = requests.get(link)
    soup = BeautifulSoup(r.text,"lxml")
    print(soup.title)
如果需要,如何制定脚本供应方案?


我们没有抓住要点。域名与协议无关。不管是http还是https,域名都会重定向到实际站点

import requests
from bs4 import BeautifulSoup

links = [
    'Titanrestoration.Ca',
    'Campbellroofing.Ca',
    'Bjmillairebuilders.Ca',
    'Rtroofing.Ca'
]

for link in links:
    link = "http://" + link
    r = requests.get(link)
    soup = BeautifulSoup(r.text,"lxml")
    print(soup.title)

如果您已经将架构连接到一些域名,您应该考虑剥离该模式并再次连接。

for link in links:
    link = link.strip("http://")
    link = "http://" + link
    r = requests.get(link)
    soup = BeautifulSoup(r.text,"lxml")
    print(soup.title)

没有架构表示您没有提供
http://
https://
。如果你知道的话,我不明白问题出在哪里?您需要有完整的链接,如
https://titanrestoration.ca
我有数千个这样的域名,有两种方案
http://
https://
。我应该选哪一个?你知道问题出在哪里了吗@Tan_007?谢谢@Tan_007的回答。现在有道理了。