Screen scraping 1

Screen scraping is a process whereby your program downloads Web pages and extracts information from them. Conceptually, the technique is very simple. You download the data and analyze it, you could, simply use urllib, get the Web page’s HTML source, and then use regular expressions or some such to extract the information.

use http://www.python.org/community/jobs/ as example

<h2>

<a class="reference external" href="http://www.dubizzle.com">DubizzleMiddle East</a>

(Dubai,United Arab Emirates)

</h2>

from urllib import urlopen
import re
     
p = re.compile('<h2><a .*? href="(.*?)">(.*?)</a>')
text = urlopen("http://www.python.org/community/jobs/").read()
for url, name in p.findall(text):
    print '%s (%s)' %(name, url)

  

posted @   小楼  阅读(247)  评论(0编辑  收藏  举报
编辑推荐:
· Brainfly: 用 C# 类型系统构建 Brainfuck 编译器
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
阅读排行:
· Tinyfox 发生重大改版
· DeepSeek 全面指南,95% 的人都不知道的9个技巧(建议收藏)
· 对比使用DeepSeek与文新一言,了解DeepSeek的关键技术论文
· Brainfly: 用 C# 类型系统构建 Brainfuck 编译器
· DeepSeekV3+Roo Code,智能编码好助手
历史上的今天:
2010-05-22 Selenium RC For Python:教程3
2010-05-22 Selenium RC For Python:教程2
2010-05-22 Selenium RC For Python:教程1
点击右上角即可分享
微信分享提示