python beautifulsoup 爬出智联

参照:http://blog.****.net/beyond_f/article/details/73974918

智联上搜索职位的时候有很多很多参数,我也不想去一一探究它的含义,我的做法是打开智联按照自己的查询条件搜索,然后copy它的url,页数自己改.

用到bs4,xlwt先安装好.

步骤:

1.给url添加headers,这里我定义了方法 def g

 def getHTML(self,url):  
        headers = {'User-Agent': 'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'}
        req = urllib.request.Request(url, headers=headers)  
        return urllib.request.urlopen(req)

2.取数据,使用BeautifulSoup

python beautifulsoup 爬出智联

3.写入excel使用xlwt

python beautifulsoup 爬出智联