Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2225810
  • 博文数量: 287
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2130
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-31 14:30
个人简介

自己慢慢积累。

文章分类

全部博文(287)

分类: Python/Ruby

2016-04-16 23:47:51

例HTML的代码如下:

点击(此处)折叠或打开

  1. <div class="tMy_card_text">
  2.                 <div class="tMy_card_name">
  3.                     <h3>
  4.                     找到我
  5.                     </h3>
  6.                     <div class="tMyname_Icon">
  7.                      </div>
  8.                 </div>
  9.                 <p>西安-高新技术产业开发区</p>
  10.                 <p>
  11.                 软件测试工程师
  12.                 </p>
  13.                 <p>
  14.                 *****有限公司
  15.                 </p>
  16.                 <p>5-7年|计算机软件</p>
  17.                                 
  18.             </div>

需要打印:“找到我”
下面列出五种方法:

点击(此处)折叠或打开

  1. print ("===the first kind of plan==")
  2. a=web.find_element_by_xpath("//*[@id='tMycontent']/div[1]/div[1]/div[3]/div/h3")
  3. print (a.text)

  4. print ("===the second kind of plan==")
  5. print (web.find_element_by_class_name("tMy_card_name").text)

  6. print ("===the third kind of plan==")
  7. print (web.find_element_by_tag_name("h3").text)

  8. print ("===the fourth kind of plan==")
  9. print (web.find_element_by_class_name("tMy_card_name").find_element_by_tag_name("h3").text)
  10. print ("===the fifth kind of plan==") 
  11. print(web.find_element_by_css_selector( '#tMycontent > div.tSider-my > div.tMy_card.clearfix > div.tMy_card_text > div > h3').text)
  12. 
    			


阅读(682) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~