zoukankan      html  css  js  c++  java
  • 爬取凤凰客户端的FUN段子

    比较喜欢凤凰新闻客户端的FUN系列文章,所以就写了Python程序来下载所有这么段子的地址。

    下面程序只是下载第一页的所有文章的url,程序修改一下,就可以爬取所有的文章。

    #!/usr/bin/python
    #-*-coding:utf-8 -*-
    
    import requests
    import json
    import re
    headers={"Host":'i.ifeng.com',
            "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0",
            "Accept":"*/*",
            "Accept-Language":"zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3",
            "Content-Type":"application/x-www-form-urlencoded",
            "X-Requested-With":"XMLHttpRequest",
            "Referer":"http://i.ifeng.com/news/djch/fun/dir?vt=5&cid=17899&mid=64DflZ"}
    
    rsp=requests.get("http://i.ifeng.com/news/djch/fun/ajaxlist.php?p=1&cid=17899&htmltype=dir",timeout=5,headers=headers)
    html=rsp.json()
    pattern=re.compile(r'aid=(.+?)&')
    aid_list=re.findall(pattern,str(html))
    for aid in aid_list:
            url="http://i.ifeng.com/news/djch/fun/news?vt=5&cid=0&aid=%s&mid=64DflZ&all=1&p=2"%aid
            print url
  • 相关阅读:
    个人工作量
    个人作业
    本周psp
    典型用户和场景总结
    排球比赛计分规则功能说明书
    我与计算机
    个人作业
    《怎样成为一个高手》读后感
    第十八周个人作业
    第十六周 项目耗时记录
  • 原文地址:https://www.cnblogs.com/tmyyss/p/4200058.html
Copyright © 2011-2022 走看看