先看看页面
这里我们以500页,为例,采用xpath选取这里的title,时间以及作者,然后再看看具体信息
红色框即为我们需要的详情信息,全部抓取后写入csv文件
import requests
from lxml import etree
import time as times
import csv
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'
}
mu_url = 'http://muchong.com/f-430-{}'
heads = ["title", "url", "author", "time", "school", "major", "need_people"]
save_path = r'D:/QQPCmgr/Desktop/xmc/school_info.csv'
with open(save_path, "w") as f:
f_csv = csv.writer(f)
f_csv.writerow(heads)
base_url = 'http://muchong.com