Toapi give you the ability to make every web site provides APIs.


  • Automatic converting HTML web site to API service.
  • Automatic caching every page of source site.
  • Automatic caching every request.
  • Support merging multiple web sites into one API service.

Get Started


$ pip install toapi


create and copy the code:

from flask import request
from htmlparsing import Attr, Text
from toapi import Api, Item

api = Api()'')
@api.route('/posts?page={page}', '/news?p={page}')
@api.route('/posts', '/news?p=1')
class Post(Item):
    url = Attr('.storylink', 'href')
    title = Text('.storylink')'')
@api.route('/posts?page={page}', '/news?p={page}')
@api.route('/posts', '/news?p=1')
class Page(Item):
    next_page = Attr('.morelink', 'href')

    def clean_next_page(self, value):
        return api.convert_string('/' + value, '/news?p={page}', request.host_url.strip('/') + '/posts?page={page}'), host='', port=5000)

run python

then open your browser and visit

you will get the result like:

  "Page": {
    "next_page": ""
  "Post": [
      "title": "Mathematicians Crack the Cursed Curve", 
      "url": ""
      "title": "Stuffing a Tesla Drivetrain into a 1981 Honda Accord", 
      "url": ""