无法使用beautifulsoup4.6.3(Anaconda)在python3.7中获取“https”

2024-04-26 06:47:04 发布

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

未能从sportsbet.com.au因为它抛出了一个异常。你知道吗

我无法读取异常,因为终端关闭太快。但是,我相信这个错误是由于从https站点而不是http站点中进行的刮取。你知道吗

例如,此https站点不工作:

https://www.sportsbet.com.au/

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

https://www.google.com/

重定向到https的网站也没有:

http://www.sportsbet.com.au/

http://en.wikipedia.org/wiki/Wiki

http://www.google.com/

但是,该网站的工作原理是:

http://www.espncricinfo.com/

代码如下:

import requests 
from bs4 import BeautifulSoup
import re

url = 'website' #insert website link.
page = requests.get(url)

soup = BeautifulSoup(page.content, 'html.parser')

input("Press enter to exit ;)")

我已尝试页=请求。获取(url,verify=False)没有成功。你知道吗


Tags: httpsorgimportcomhttpurl站点www