вот из книжки взял код
from http.client import HTTPConnection data = "" header = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0", "Accept": "text/html, text/plain, application/xml", "Accept-Language": "ru, ru-RU", "Accept-Charset": "windows-1251", "Referer": "" } con = HTTPConnection("masteram.us") con.request("GET", "index.php", headers=header) result = con.getresponse() print(result.read().decode("cp1251")) con.close() print("hello")
и теперь при обрашению к локальному хостингу test1.ru
у меня выдает
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> <hr> <address>Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/1.0.1c PHP/5.3.13 Server at test1.ru Port 80</address> </body></html> hello
а к сайту ошибку
Traceback (most recent call last):
File “C
Users/Николай/Desktop/IProfiWM/get.py”, line 12, in <module>result = con.getresponse()
File “C:\Python33\lib\http\client.py”, line 1143, in getresponse
response.begin()
File “C:\Python33\lib\http\client.py”, line 354, in begin
version, status, reason = self._read_status()
File “C:\Python33\lib\http\client.py”, line 336, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: <html>
подскажите в чем проблема