Posted in Python onFebruary 25, 2014
#encoding:utf-8 import socket import htmllib,formatter def open_socket(host,servname): s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) port=socket.getservbyname(servname) s.connect((host,port)) return s host='' host=input('请输入网址\n') mysocket=open_socket(host,'http') message='GET http://%s/\n\n'%(host,) mysocket.send(message) file=mysocket.makefile() htmldata=file.read() file.close() parser=htmllib.HTMLParser(formatter.NullFormatter()) parser.feed(htmldata) print '\n'.join(parser.anchorlist) parser.close()
python实现网页链接提取的方法分享
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@