【问题标题】:Requests.get does not work, Failed to establish a new connectionRequests.get 不起作用,无法建立新连接
【发布时间】:2020-01-12 07:34:41
【问题描述】:

我正在尝试进行网络抓取。首先代码可以工作,但后来它没有。代码是

import requests
import hashlib
from bs4 import BeautifulSoup

def sha512(x):
    m = hashlib.sha512(x.encode())
    return m.hexdigest()

session = requests.Session()
session.cookies["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36"

r = session.post("https://ringzer0ctf.com/login", data={"username":"myusername","password":"mypass"})
r = session.get("https://ringzeractf.com/challenges/13")

soup = BeautifulSoup(r.text, 'html.parser')

它给出了类似的错误

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ringzeractf.com', port=443): Max retries exceeded 
with url: /challenges/13 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x04228490>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

【问题讨论】:

    标签: python beautifulsoup python-requests screen-scraping


    【解决方案1】:

    您在 GET 请求中的 URL 错误。将ringzeractf 更改为ringzer0ctf

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 2019-05-30
      • 1970-01-01
      • 2016-02-22
      • 2016-01-11
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多