Форум сайта python.su
0
вот у меня возникла еше одна ошибка, не получается получить html страницу в Python3
вот из книжки взял код
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")
<!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
Users/Николай/Desktop/IProfiWM/get.py”, line 12, in <module>Офлайн
6
Your browser sent a request that this server could not understand.
/index.php, наверное
Офлайн
0
wbtнепонял что?
Your browser sent a request that this server could not understand./index.php, наверное
Офлайн
Изменить
con.request(“GET”, “index.php”, headers=header)
на
con.request(“GET”, “/index.php”, headers=header)
Офлайн