【python 页面抓取文章生成word】

第一步 requests发送请求

 response = requests.get(f'{url}/{page_num}', headers=headers)
 response.encoding = response.apparent_encoding

第二步 获取页面属性文章列表

 soup = BeautifulSoup(content, 'html.parser')
 article_table = soup.find('div', class_='article-list')  # 获取到文章列表

第三步 pypandoc 生成word

pypandoc.convert_file(name, 'docx', outputfile = nameWord)

你可能感兴趣的:(python,python,word,开发语言)