python达成网页链接提取的办法分享

作者: 数据库信息  发布:2019-12-06

复制代码 代码如下:

复制代码 代码如下:

#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 ,)
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()

#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 ,)
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达成网页链接提取的办法分享

关键词: 金沙澳门官网