赞
踩
""""
进入头条首页,在右边输入关键字,进入搜索页面,主要爬取搜索的到的图片以及图片的标题
""""
""""
python版本:python3.6.5
""""
#手动输入搜索关键字和要爬取的页数,默认从第一页开始爬取
- end_page = int(input('请输入结束页面:'))
- keyword = input('请输入查找关键字:')
#获取网页url
- def get_url():
- url = 'https://www.toutiao.com/search_content/?'
- # 定义url的参数
- params = {
- 'offset': '1',
- 'format': 'json',
- 'keyword': keyword,
- 'autoload': 'true',
- 'count': '20',
- 'cur_tab': '1',
- 'from': 'search_tab'
- }
- #定义请求头
- headers = {
- 'referer': 'https://www.toutiao.com/search/?keywor
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。