欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實(shí)現(xiàn)網(wǎng)頁鏈接提取的方法分享

 更新時(shí)間:2014年02月25日 10:11:33   作者:  
這篇文章主要介紹了python實(shí)現(xiàn)的網(wǎng)頁鏈接提取的方法,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

#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('請(qǐng)輸入網(wǎng)址\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()

相關(guān)文章

最新評(píng)論