爬取腾讯招聘职位列表和详情

from urllib import request
from bs4 import BeautifulSoup
urls = []
def qq():
url = "https://hr.tencent.com/position.php?keywords=python&lid=2196&tid=87"
a = request.urlopen(url)
b = a.read()
soup = BeautifulSoup(b,'lxml')
tr1 = soup.select("tr[class='even']")
tr2 = soup.select("tr[class='odd']")
tr = tr1 + tr2
print('找到的职位列表如下:')
for k in tr:
name = k.select('td a')[0].get_text()
href = k.select('td a')[0].attrs['href']
leixing = k.select('td')[1].get_text()
addr = k.select('td')[3].get_text()
urls.append('https://hr.tencent.com/'+href)
print(name)
print('*'*20)

def zpxq():
print('找到的职位详情如下:')
for url in urls:
a = request.urlopen(url)
b = a.read()
soup = BeautifulSoup(b,'lxml')
tr = soup.select("tr")
for k in tr:
name = k.select("td")[0].get_text()
print(name)
print('=='*15)

if __name__ == '__main__':
qq()
zpxq()

转载于:https://www.cnblogs.com/billchen1991/p/10341713.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值