关于selenium的一些书籍和资料

书籍:

Selenium Testing Tools Cookbook

http://www.amazon.com/Selenium-Testing-Cookbook-Gundecha-Unmesh/dp/1849515743/?tag=seleniumfaq-20


Selenium 2 Testing Tools: Beginner's Guide

http://www.amazon.com/Selenium-Testing-Tools-Beginners-Guide/dp/1849518300/?tag=seleniumfaq-20


Selenium Simplified

http://www.amazon.com/Selenium-Simplified-Alan-John-Richardson/dp/0956733239/?tag=seleniumfaq-20


Selenium WebDriver Practical Guide

http://www.amazon.com/gp/product/B00I2ORN2O/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00I2ORN2O&linkCode=as2&tag=seleniumfaq-20


Selenium Webdriver in Java: Learn With Examples

http://www.amazon.com/gp/product/1495450201/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1495450201&linkCode=as2&tag=seleniumfaq-20


New Selenium WebDriver Tutorial Book


站点:

官网地址:http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp

google Code地址https://code.google.com/p/selenium/w/list

github地址: https://github.com/SeleniumHQ/selenium/tree/master/docs




使用Selenium库可以方便地爬取当当网上的Python书籍信息。Selenium是一个自动化测试工具,可以模拟用户在浏览器上的操作,通过它可以实现自动登录网页、点击页面元素、获取网页内容等功能。 首先,我们需要安装Selenium库并下载相应的驱动程序来控制浏览器。常用的浏览器驱动有ChromeDriver和GeckoDriver,我们选择其中之一安装。 安装完成后,导入Selenium库,并创建一个浏览器实例。 ```python from selenium import webdriver driver = webdriver.Chrome() # 使用Chrome浏览器驱动 # 或者使用GeckoDriver # driver = webdriver.Firefox() ``` 接下来,使用浏览器实例打开当当网的Python书籍页面。 ```python driver.get("http://search.dangdang.com/?key=python&act=input") ``` 然后,我们可以通过Selenium的find_elements方法选取页面上的书籍元素,并提取出我们需要的书籍信息。 ```python book_elements = driver.find_elements_by_class_name("line1") # 通过class_name属性选取书籍元素 for book_element in book_elements: book_title = book_element.find_element_by_tag_name("a").text # 选取书籍标题 book_author = book_element.find_element_by_class_name("search_book_author").text # 选取书籍作者 book_price = book_element.find_element_by_class_name("search_now_price").text # 选取书籍价格 print(book_title, book_author, book_price) ``` 最后,关闭浏览器实例。 ```python driver.quit() ``` 通过以上步骤,我们已经成功使用Selenium爬取了当当网上的Python书籍信息。需要注意的是,使用Selenium进行爬虫时,为了避免被网站封禁,可以设置合理的访问频率,并设置合适的User-Agent,模拟真实用户的行为。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

上帝De助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值