Python爬虫防封杀方法集合
查找出陷阱url和不可见的value代码 from selenium import webdriver#from selenium.webdriver.remote.webelement import WebElementurl = 'http://pythonscraping.com/pages/itsatrap.html'driver = webdriver.PhantomJS(executable_path="phantomjs.exe") driver.get(url) links = driver.find_elements_by_tag_name("a")for link in links:if not link.is_displayed():print "the link "+link.get_attribute("href")+"is a trap"fields = driver.find_elements_by_tag_name("input")for field in fields:if not field.is_displayed():print "do not change value of "+field.get_attribute("name") 结果就是 the link http://pythonscraping.com/dontgohereis a trapdo not change value of phonedo not change value of email 方法5:采用分布式爬取基于Python,scrapy,redis的分布式爬虫实现框架
采用Scrapy的例子,请参考这里基于Scrapy对Dmoz进行抓取 方法6:进行模拟登陆这个就太多了,一般用Selenium,可以结合Firefox或者是无头浏览器PhantomJS,这个做的东西比较多了,如果感兴趣,可以点击这些,进行查看,方法,代码,解析,一应俱全
Pay Attention
注:相关网站建设技巧阅读请移步到建站教程频道。 (编辑:应用网_丽江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |