G
G
ganduras3812018-07-17 21:27:25
Python
ganduras381, 2018-07-17 21:27:25

Why doesn't http get request work for a single site?

Request the following function:

def simple_get(url):
    """
    Attempts to get the content at `url` by making an HTTP GET request.
    If the content-type of response is some kind of HTML/XML, return the
    text content, otherwise return None.
    """
    try:
        with closing(get(url, stream=True)) as resp:
            if is_good_response(resp):
                return resp.content
            else:
                return None

It is used like this:
from mathematicians import simple_get
import os
from bs4 import BeautifulSoup

raw_html = simple_get('https://dictionary.cambridge.org')
html = BeautifulSoup(raw_html, 'html.parser')
print(html)

An error occurs corresponding to the function:
Error during requests to https://dictionary.cambridge.org/dictionary : ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Request https://vk.com and other sites with the augmented protocol works, as well as sites with http.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question