Chainguys 2021-10-23 08:56 采纳率: 93.6%
浏览 63
已结题

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


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)')))

  • 写回答

2条回答 默认 最新

  • -Undefined_ 2021-10-23 09:46
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月31日
  • 已采纳回答 10月23日
  • 创建了问题 10月23日

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装