Scrapy reptiles learning needs, have to design xpath knowledge training.
Exercise xpath use. Reference: https://cuiqingcai.com/2621.html
1, ready resources
[root@master xpaths]# cat hello.html
<html><body>
<div>
<ul>
<li class="item-0"><a href="link1.html">first item</a></li>
<li class="item-1"><a href="link2.html">second item</a></li>
<li class="item-inactive"><a href="link3.html">third item</a></li>
<li class="item-1"><a href="link4.html">fourth item</a></li>
<li class="item-0"><a href="link5.html">fifth item</a></li>
</ul>
</div>
</body></html>
Address and file access
2, demonstrate basic environment
3, // path usage.
Page xpath get the absolute path.
Results: / html / body / div / ul / li [1] / a
Below, // normal use, select a document from the nodes in the current node matches the selected, regardless of their location .
4, @ select Properties
The method of obtaining a label attribute.
Above, href link address to obtain information.
Processing properties in the middle position.
carry out.