Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple site routing problems. #38

Closed
elliotgao2 opened this issue Dec 8, 2017 · 1 comment
Closed

Multiple site routing problems. #38

elliotgao2 opened this issue Dec 8, 2017 · 1 comment

Comments

@elliotgao2
Copy link
Owner

elliotgao2 commented Dec 8, 2017

The example:

from toapi import XPath, Item, Api

api = Api()


class Movie(Item):
    __base_url__ = 'http://www.dy2018.com'

    url = XPath('//b//a[@class="ulink"]/@href')
    title = XPath('//b//a[@class="ulink"]/text()')

    class Meta:
        source = XPath('//table[@class="tbspan"]')
        route = '/'


class Post(Item):
    __base_url__ = 'https://news.ycombinator.com/'

    url = XPath('//a[@class="storylink"]/@href')
    title = XPath('//a[@class="storylink"]/text()')

    class Meta:
        source = XPath('//tr[@class="athing"]')
        route = '/'

api.register(Movie)
api.register(Post)

api.serve()
@elliotgao2
Copy link
Owner Author

elliotgao2 commented Dec 8, 2017

When I visite http://127.0.0.1:5000/, it excepted to result in:

{
    post:[],
    movie:[]
}

When I visit http://127.0.0.1:5000/www.dy2018.com/, it excepted to result in:

{
    movie:[]
}

When I visit http://127.0.0.1:5000/news.ycombinator.com/, it excepted to result in:

{
    post:[]
}

elliotgao2 added a commit that referenced this issue Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant