Recently contacted Python crawlers to crawl the school news headlines, dates, clicks as an example, to record the progress of the work
Currently, the process of feeling a Python crawler is no more than two steps:
Step1. Obtaining a Web page URL (using the Python library function import urllib2)
Step2. Use regular expressions to match, find, and manipulate strings in HTML
Self-feeling sublime Text2 editor really easy to use, after the deployment of Python will not be like Wingide, notepad++ as there are so many headaches, recommended
School News Network: Southwest Jiaotong University News
#-*-coding:utf-8-*-import urllib2import sysimport reimport os#***********fuction define************ #def Extract_url ( Info): rege= "<li><span class=\" title\ "><a href=\" (. *?) \ ">" #fei tan lan mo shi Re_url = re.findall (Rege, info) N=len (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 = "
Attached: Python Crawler Learning Series Tutorials
Python Crawl news headlines, dates, clicks