百思不得其解,为什么会报错?


import requests
from lxml import etree
from bs4 import BeautifulSoup
import time
import pandas as pd
import json

hd = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36",
    "Accept": "application/json",
    "Cache-Control": "no-cache"
}

link="https://www.dtc.capital/portfolio"


resp = requests.get(link,headers=hd)

total = []
print(resp.status_code)
html = BeautifulSoup(resp.text, "lxml")
#print(html)
total = []
temp = html.find_all("div", class_="_1vNJf")

print(len(temp))

#print(temp[0:2])
for i in temp:
    try:
        name1 = i.find("span", style="text-decoration:underline").text.strip()
        link = i.find("a",)['href'].strip()
        total.append([name1, link])
    except Exception as e:
        pass

    try:
        name2 = i.find("span", style="text-decoration:underline;").text.strip()
        link = i.find("a",)['href'].strip()
        total.append([name2, link])
    except Exception as e:
        pass
ns = pd.DataFrame(total)
date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
path = "/Users/paul/jpn traffic/ana/dtc/"
ns.to_csv(path + date + '.csv', index=None)
print("dtc finished")

quit()


raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.dtc.capital', port=443): Max retries exceeded with url: /portfolio (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.dtc.capital', port=443): Max retries exceeded with url: /portfolio (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

你这个网站需要科学上网才能访问🤭

resp = requests.get(link,headers=hd,verify=False)