谁能建议我采用这些字段的xpath

时间:2019-02-11 09:58:04

标签: python xpath

<div class="the_content">
			<p><strong>Niki Jones Agency, Inc</strong></p>
<p>Ms. Niki Jones</p>
<p>39 Front Street</p>
<p>Port Jervis</p>
<p>NY,&nbsp;12771</p>
<p>(845) 856-1266</p>
<p>njones@nikijones.com</p>
<p>www.Nikijones.com</p>
<p>20 Years in the PR &amp; Marketing business : Graphic design, Publications, Websites design&amp; Development, Digital Ads, Campaigns, Social Media, Direct Mail, Website security,ADA compliance 508</p>
<div class="apss-social-share apss-theme-1 clearfix">




<div class="the_content">
			<p><strong>JMB Electric Supply, LLC</strong></p>
<p>Joanne M. Barish</p>
<p>17 Belmont Street</p>
<p>White Plains, New York 10605</p>
<p>Tel:&nbsp;(914) 260-1895</p>
<p>Fax: 914-722-3277</p>
<p>Email:&nbsp;jmbelec@optionline.net</p>
<p>Website:&nbsp;http://jmbelec.net/</p>
<p>Description: Master distributor of Electronic and Magnetic Low Voltage Transformers &amp; Ballasts selling throughout the United States, as well as internationally.</p>
<div class="apss-social-share apss-theme-1 clearfix">

1 个答案:

答案 0 :(得分:0)

第1步:在xpath下面使用以获取所有div元素。

/div[@class='the_content']

第2步:对于每个div元素,

公司名称

/p/strong

对于其他p个标签:

/p[2]

2是第二个p标签。因此,您可以使用3,4,5 ...

请参阅https://www.w3schools.com/xml/xml_xpath.asp