xpath的使用

怎么用xpath找到登陆的链接

第1个回答  2015-05-03
您好,Scrapy是基于python的开源爬虫框架,使用起来也比较方便。具体的官网档:http://doc.scrapy.org/en/latest/

  之前以为了解python就可以直接爬网站了,原来还要了解HTML,XML的基本协议,在了解基础以后,在了解下xpath的基础上,再使用正则表达式(python下的re包提供支持)提取一定格式的信息(比如说url),就比较容易处理网页了。

xpath是Scrapy下快速提取特定信息(如title,head,href等)的一个接口。

几个简单的例子:

/html/head/title: 选择HTML文档<head>元素下面的<title>
标签。
/html/head/title/text(): 选择前面提到的<title> 元素下面的文本内容
//td: 选择所有
<td> 元素
//div[@class="mine"]: 选择所有包含 class="mine" 属性的div 标签元素。
<?xml version="1.0" encoding="ISO-8859-1"?> <catalog>
<cd country="USA">
<title>Empire Burlesque</title> <artist>Bob Dylan</artist> <price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price>9.90</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title> <artist>Dolly Parton</artist> <price>9.90</price>
</cd> </catalog>追问

谢谢,最后用/html/body/div[3]/div[1]/div[1]/div[3]/a[6]的方式找到登陆。

本回答被提问者采纳
相似回答
大家正在搜