GithubHelp home page GithubHelp logo

aspider's People

Contributors

gxtrobot avatar iorilu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aspider's Issues

请问大神,这种异步的该咋处理呢?求解答

import json
from collections import namedtuple
from aspider.routeing import get_router
from aspider import aspider
from requests_html import HTML

Woshipm = namedtuple('Article', ['cateory', 'comment', 'date','id','permalink','snipper','view'])

router = get_router()



woshipm_list = []


@router.route('/page/<no>')
def process_page(text):
    html = HTML(html=text)
    json_data = json.loads(html.text)['payload']
    cateorys = [i['cateory'] for i in json_data]
    comments = [i['comment'] for i in json_data]
    dates =    [i['date'] for i in json_data]
    ids = [i['id'] for i in json_data]
    permalinks = [i['permalink'] for i in json_data]
    snippers = [i['snipper'] for i in json_data]
    views = [i['view'] for i in json_data]
    for cateory, comment, date,id,permalink,snipper,view in zip(cateorys,comments,dates,ids ,permalinks, snippers,views):

        woshipm_list.append(Woshipm(cateory, comment, date,id,permalink,snipper,view))


def main():
    #options = {'roots': ['http://www.woshipm.com/__api/v1/stream-list/page/{}'.format(i) for i in range(1,5000)]}
    options = {'roots': 'http://www.woshipm.com/__api/v1/stream-list/page/1'}
    stats = aspider.download(extra_args=options)
    stats.report()
    fname = 'woshipm.txt'
    sorted_woshipm = sorted(woshipm_list, key=lambda m: m.rank)
    with open(fname, 'w',encoding='utf-8') as f:
        for movie in sorted_woshipm:
            print(f'#{movie.rank:<10} {movie.score:<10.2f} - {movie.title}')
            print(f'#{movie.rank:<10} {movie.score:<10.2f} - {movie.title}', file=f)


if __name__ == "__main__":
    main()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.