Extract HTML Title, Description, Keywords(Chilkat/Python学习二 )
来源:互联网 发布:mysql limit offaet 编辑:程序博客网 时间:2024/06/05 04:18
既然自己要学习Chilkat,那就接着写他的东西吧;
好了,开始吧!
首先你要学习这篇内容你必须了解python语法,python很简单,但是做的事不简单,这也是我学习他的原因;还有你必学安装Chilkat,具体细节去看我的
Getting Started Spidering a Site使用Chilkat(python)练习的一个爬虫(from :http://www.example-code.com)
http://blog.csdn.net/Xiao_Qiang_/archive/2008/08/23/2820293.aspx一、源码
- from extra import chilkat
- # The Chilkat Spider component/library is free.
- spider = chilkat.CkSpider()
- # The spider object crawls a single web site at a time. As you'll see
- # in later examples, you can collect outbound links and use them to
- # crawl the web. For now, we'll simply spider 10 pages of chilkatsoft.com
- spider.Initialize("http://www.vtchina.com/")
- # Add the 1st URL:
- spider.AddUnspidered("http://www.vtchina.com/")
- # Begin crawling the site by calling CrawlNext repeatedly.
- for i in range(0,10):
- success = spider.CrawlNext()
- if (success == True):
- # Show the URL of the page just spidered.
- print spider.lastUrl()
- # The HTML META keywords, title, and description are available in these properties:
- print spider.lastHtmlTitle()
- info = spider.lastHtmlDescription()
- HtmlDescription = unicode(info,"utf-8")
- print HtmlDescription
- print spider.lastHtmlKeywords()
- # The HTML is available in the LastHtml property
- else:
- # Did we get an error or are there no more URLs to crawl?
- if (spider.get_NumUnspidered() == 0):
- print "No more URLs to spider"
- else:
- print spider.lastErrorText()
- # Sleep 1 second before spidering the next URL.
- spider.SleepMs(1000)
- def lastHtmlTitle(*args):
- utfchar = _chilkat.CkSpider_lastHtmlTitle(*args)
- info = unicode(utfchar,"utf-8")
- return info
由于是很入门的例子,代码没啥具体可说的,就是取页面title的功能。
- Extract HTML Title, Description, Keywords(Chilkat/Python学习二 )
- asp.net 动态设置标题title、meta(keywords、description)
- 标准的网站title、keywords、description写法
- 动态设置标题title、keywords、description
- Magento修改页面Title,Keywords和Description
- 网站title/keywords/description的编写原则
- 自由编辑ZenCart的title、description、keywords
- 标签- dede首页 title keywords description
- 正确设置网站title、keywords、description
- C# 获取网页标题title、keywords、description 的代码(winform)
- 网站优化之title、keywords、description标签写法
- Zen Cart首页title,keywords,description设置方法
- Zen Cart 首页的 title,keywords,description设置
- 怎样正确设置网站title、keywords、description比较标准
- Zen Cart 首页的title,keywords,description设置
- 动态修改页面的Title, Keywords and Description
- Yii如何添加title、keywords和description,简称TDK
- 怎样正确设置网站title、keywords、description比较标准
- INSERT
- SQLSERVER2000-单用户模式
- SQLSERVER2000-以前的某个程序安装已在安装计算机上创建挂起的文件操作
- 移动开发环境的搭建步骤及开发工具下载
- 宇宙爆炸的三种演化模型
- Extract HTML Title, Description, Keywords(Chilkat/Python学习二 )
- 电脑轻松扩容 教你安装双硬盘
- ....
- 老程序员十年生涯黯然总结
- 从现在开始我进入了linux的世界,在这里说一声“Hello World!”,让自己的心情放飞!
- POSA2 前言
- 大爆炸“奇点”概念的提出
- 如果我现在能借书
- 企业采用SaaS服务是IT投资与回报的关键