企业微信网站开发文档,网站注册的账号怎么注销,2022年企业所得税最新标准,无锡哪家网站做的比较好最近接触Python爬虫#xff0c;以爬取学校新闻网新闻标题、日期、点击量为例#xff0c;记录一下工作进度目前#xff0c;感觉Python爬虫的过程无非两步#xff1a;Step1.获取网页url(利用Python库函数import urllib2)Step2.利用正则表达式对html中的字符串进行匹配、查找等…最近接触Python爬虫以爬取学校新闻网新闻标题、日期、点击量为例记录一下工作进度目前感觉Python爬虫的过程无非两步Step1.获取网页url(利用Python库函数import urllib2)Step2.利用正则表达式对html中的字符串进行匹配、查找等操作自我感觉sublime text2编辑器真心好用部署Python后不会像WingIDE、notepad那样存在那么多头疼的小问题推荐使用# -*- coding: UTF-8 -*-import urllib2import sysimport reimport os#***********fuction define************#def extract_url(info):rege#fei tan lan mo shire_url re.findall(rege, info)nlen(re_url)for i in range(0,n):re_url[i]http://news.swjtu.edu.cn/re_url[i]return re_urldef extract_title(sub_web):re_key \r\n (.*)\r\n title re.findall(re_key,sub_web)return titledef extract_date(sub_web):re_key 日期(.*?) date re.findall(re_key,sub_web)return datedef extract_counts(sub_web):re_key 点击数(.*?) counts re.findall(re_key,sub_web)return counts#*************main**************#fpopen(output.txt,w)content urllib2.urlopen(http://news.swjtu.edu.cn/ShowList-82-0-1.shtml).read()urlextract_url(content)stringnlen(url)print nfor i in range(0,n):sub_web urllib2.urlopen(url[i]).read()sub_title extract_title(sub_web)stringsub_title[0]string sub_date extract_date(sub_web)string日期sub_date[0]string sub_counts extract_counts(sub_web)string点击数sub_counts[0]string\n# print stringprint stringfp.close()原文http://blog.csdn.net/u012717411/article/details/46486679