使用lxml获取HTML的所有链接 [英] get all the links of HTML using lxml

查看:176
本文介绍了使用lxml获取HTML的所有链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用lxml从html页面中找出所有网址及其名称.

I want to find out all the urls and its name from a html page using lxml.

我可以解析url并找出问题,但是有什么简单的方法可以使用lxml查找所有url链接?

I can parse the url and can find out this thing but is there any easy way from which I can find all the url links using lxml?

推荐答案

from lxml.html import parse
dom = parse('http://www.google.com/').getroot()
links = dom.cssselect('a')

这篇关于使用lxml获取HTML的所有链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆