HTTP 배너 그래버를 만드는 데 관심이 있습니다. 그러나 포트 80의 서버에 연결할 때 뭔가 (예 : "HEAD/HTTP/1.1")를 보내면 recv가 나에게 아무것도 반환하지 않습니다. 내가 netcat ..을 말하자면 그것을 할 때처럼HTTP 배너 Grabbing with Python
나는 이것에 관해 어떻게 갈 것이냐?
감사합니다.
HTTP 배너 그래버를 만드는 데 관심이 있습니다. 그러나 포트 80의 서버에 연결할 때 뭔가 (예 : "HEAD/HTTP/1.1")를 보내면 recv가 나에게 아무것도 반환하지 않습니다. 내가 netcat ..을 말하자면 그것을 할 때처럼HTTP 배너 Grabbing with Python
나는 이것에 관해 어떻게 갈 것이냐?
감사합니다.
urllib2
module을 사용해보세요.
>>> data = urllib2.urlopen('http://www.example.com').read()
>>> print data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>Example Web Page</TITLE>
</HEAD>
<body>
<p>You have reached this web page by typing "example.com",
"example.net",
or "example.org" into your web browser.</p>
<p>These domain names are reserved for use in documentation and are not available
for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC
2606</a>, Section 3.</p>
</BODY>
</HTML>
>>>
예를 들어, 더 세밀한 포인트를 놓칠 수 있습니다. content-type
헤더를 보려면
>>> stream = urllib2.urlopen('http://www.example.com')
>>> stream.headers['content-type']
'text/html; charset=UTF-8'
>>> data = stream.read()
>>> print data[:100]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=
>>>
답장을 검색하는 방법은 무엇입니까? 스크립트를 식별 할 수있게하려면 컨텐츠 유형을 말하고 그 내용을 출력 하시겠습니까 ?? – Kaep
내용 유형 예제 (추가)를 참조하십시오. 사실, 당신은 BeautifulSoup을 봐야합니다 - http://stackoverflow.com/questions/tagged/beautifulsoup – gimel