1
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flask API一覧をスクレイピングしました

Posted at

導入

FlaskというPythonのWebフレームワークの全体像が知りたくて、APIリファレンスを眺めていたが、メソッド名だけを概観できないのでスクレイピングしました。というわけで公開します。あまり役立つとは思えないけど、あくまで全体像を見渡すために見てください。

感想はブログに

全体を眺めての感想は、ブログに書く予定ですので、できたらリンク貼ります。

スクレイピングのコード

一応。

def get_links(url):
    import requests
    from bs4 import BeautifulSoup as soup
    import re
    result = requests.get(url)
    page = result.text
    doc = soup(page, "html5lib")
    # links = [element.get('id') for element in doc.find_all(id=re.compile('^flask.'))]
    links = [element.get('id') for element in doc.find_all(class_="section")]
    return links

if __name__ == '__main__':
    import sys
    for url in sys.argv[1:]:
        for num, link in enumerate(get_links(url), start=1):
            print("-", num, "`%s`" % link)
        print()

結果のAPI

セクションとそれぞれのメソッド・プロパティを列挙しただけど、それでもFlaskで何ができるのかという雰囲気は掴める。
特に説明はしません。メソッド・プロパティの横の番号には、数を数える以外の意味はありません。

API Sections

  • application-object
  • blueprint-objects
  • incoming-request-data
  • response-objects
  • sessions
  • session-interface
  • test-client
  • application-globals
  • useful-functions-and-classes
  • message-flashing
  • module-flask.json
  • template-rendering
  • configuration
  • extensions
  • stream-helpers
  • useful-internals
  • signals
  • class-based-views
  • url-route-registrations
  • view-function-options
  • command-line-interface
Application Object
  • 1 flask.Flask
  • 2 flask.Flask.add_template_filter
  • 3 flask.Flask.add_template_global
  • 4 flask.Flask.add_template_test
  • 5 flask.Flask.add_url_rule
  • 6 flask.Flask.after_request
  • 7 flask.Flask.after_request_funcs
  • 8 flask.Flask.app_context
  • 9 flask.Flask.app_ctx_globals_class
  • 10 flask.Flask.auto_find_instance_path
  • 11 flask.Flask.before_first_request
  • 12 flask.Flask.before_first_request_funcs
  • 13 flask.Flask.before_request
  • 14 flask.Flask.before_request_funcs
  • 15 flask.Flask.blueprints
  • 16 flask.Flask.cli
  • 17 flask.Flask.config
  • 18 flask.Flask.config_class
  • 19 flask.Flask.context_processor
  • 20 flask.Flask.create_global_jinja_loader
  • 21 flask.Flask.create_jinja_environment
  • 22 flask.Flask.create_url_adapter
  • 23 flask.Flask.debug
  • 24 flask.Flask.default_config
  • 25 flask.Flask.dispatch_request
  • 26 flask.Flask.do_teardown_appcontext
  • 27 flask.Flask.do_teardown_request
  • 28 flask.Flask.endpoint
  • 29 flask.Flask.error_handler_spec
  • 30 flask.Flask.errorhandler
  • 31 flask.Flask.extensions
  • 32 flask.Flask.full_dispatch_request
  • 33 flask.Flask.get_send_file_max_age
  • 34 flask.Flask.got_first_request
  • 35 flask.Flask.handle_exception
  • 36 flask.Flask.handle_http_exception
  • 37 flask.Flask.handle_url_build_error
  • 38 flask.Flask.handle_user_exception
  • 39 flask.Flask.has_static_folder
  • 40 flask.Flask.init_jinja_globals
  • 41 flask.Flask.inject_url_defaults
  • 42 flask.Flask.instance_path
  • 43 flask.Flask.iter_blueprints
  • 44 flask.Flask.jinja_env
  • 45 flask.Flask.jinja_environment
  • 46 flask.Flask.jinja_loader
  • 47 flask.Flask.jinja_options
  • 48 flask.Flask.json_decoder
  • 49 flask.Flask.json_encoder
  • 50 flask.Flask.log_exception
  • 51 flask.Flask.logger
  • 52 flask.Flask.logger_name
  • 53 flask.Flask.make_config
  • 54 flask.Flask.make_default_options_response
  • 55 flask.Flask.make_null_session
  • 56 flask.Flask.make_response
  • 57 flask.Flask.make_shell_context
  • 58 flask.Flask.name
  • 59 flask.Flask.open_instance_resource
  • 60 flask.Flask.open_resource
  • 61 flask.Flask.open_session
  • 62 flask.Flask.permanent_session_lifetime
  • 63 flask.Flask.preprocess_request
  • 64 flask.Flask.preserve_context_on_exception
  • 65 flask.Flask.process_response
  • 66 flask.Flask.propagate_exceptions
  • 67 flask.Flask.register_blueprint
  • 68 flask.Flask.register_error_handler
  • 69 flask.Flask.request_class
  • 70 flask.Flask.request_context
  • 71 flask.Flask.response_class
  • 72 flask.Flask.route
  • 73 flask.Flask.run
  • 74 flask.Flask.save_session
  • 75 flask.Flask.secret_key
  • 76 flask.Flask.select_jinja_autoescape
  • 77 flask.Flask.send_file_max_age_default
  • 78 flask.Flask.send_static_file
  • 79 flask.Flask.session_cookie_name
  • 80 flask.Flask.session_interface
  • 81 flask.Flask.shell_context_processor
  • 82 flask.Flask.shell_context_processors
  • 83 flask.Flask.should_ignore_error
  • 84 flask.Flask.static_folder
  • 85 flask.Flask.teardown_appcontext
  • 86 flask.Flask.teardown_appcontext_funcs
  • 87 flask.Flask.teardown_request
  • 88 flask.Flask.teardown_request_funcs
  • 89 flask.Flask.template_context_processors
  • 90 flask.Flask.template_filter
  • 91 flask.Flask.template_global
  • 92 flask.Flask.template_test
  • 93 flask.Flask.test_client
  • 94 flask.Flask.test_client_class
  • 95 flask.Flask.test_request_context
  • 96 flask.Flask.testing
  • 97 flask.Flask.trap_http_exception
  • 98 flask.Flask.update_template_context
  • 99 flask.Flask.url_build_error_handlers
  • 100 flask.Flask.url_default_functions
  • 101 flask.Flask.url_defaults
  • 102 flask.Flask.url_map
  • 103 flask.Flask.url_rule_class
  • 104 flask.Flask.url_value_preprocessor
  • 105 flask.Flask.url_value_preprocessors
  • 106 flask.Flask.use_x_sendfile
  • 107 flask.Flask.view_functions
  • 108 flask.Flask.wsgi_app
Blueprint Objects
  • 109 flask.Blueprint
  • 110 flask.Blueprint.add_app_template_filter
  • 111 flask.Blueprint.add_app_template_global
  • 112 flask.Blueprint.add_app_template_test
  • 113 flask.Blueprint.add_url_rule
  • 114 flask.Blueprint.after_app_request
  • 115 flask.Blueprint.after_request
  • 116 flask.Blueprint.app_context_processor
  • 117 flask.Blueprint.app_errorhandler
  • 118 flask.Blueprint.app_template_filter
  • 119 flask.Blueprint.app_template_global
  • 120 flask.Blueprint.app_template_test
  • 121 flask.Blueprint.app_url_defaults
  • 122 flask.Blueprint.app_url_value_preprocessor
  • 123 flask.Blueprint.before_app_first_request
  • 124 flask.Blueprint.before_app_request
  • 125 flask.Blueprint.before_request
  • 126 flask.Blueprint.context_processor
  • 127 flask.Blueprint.endpoint
  • 128 flask.Blueprint.errorhandler
  • 129 flask.Blueprint.get_send_file_max_age
  • 130 flask.Blueprint.has_static_folder
  • 131 flask.Blueprint.jinja_loader
  • 132 flask.Blueprint.make_setup_state
  • 133 flask.Blueprint.open_resource
  • 134 flask.Blueprint.record
  • 135 flask.Blueprint.record_once
  • 136 flask.Blueprint.register
  • 137 flask.Blueprint.register_error_handler
  • 138 flask.Blueprint.route
  • 139 flask.Blueprint.send_static_file
  • 140 flask.Blueprint.static_folder
  • 141 flask.Blueprint.teardown_app_request
  • 142 flask.Blueprint.teardown_request
  • 143 flask.Blueprint.url_defaults
  • 144 flask.Blueprint.url_value_preprocessor
Incoming Request Data
  • 145 flask.Request
  • 146 flask.Request.form
  • 147 flask.Request.args
  • 148 flask.Request.values
  • 149 flask.Request.cookies
  • 150 flask.Request.stream
  • 151 flask.Request.headers
  • 152 flask.Request.data
  • 153 flask.Request.files
  • 154 flask.Request.environ
  • 155 flask.Request.method
  • 156 flask.Request.path
  • 157 flask.Request.full_path
  • 158 flask.Request.script_root
  • 159 flask.Request.url
  • 160 flask.Request.base_url
  • 161 flask.Request.url_root
  • 162 flask.Request.is_xhr
  • 163 flask.Request.blueprint
  • 164 flask.Request.endpoint
  • 165 flask.Request.get_json
  • 166 flask.Request.is_json
  • 167 flask.Request.json
  • 168 flask.Request.max_content_length
  • 169 flask.Request.module
  • 170 flask.Request.on_json_loading_failed
  • 171 flask.Request.routing_exception
  • 172 flask.Request.url_rule
  • 173 flask.Request.view_args
  • 174 flask.request
Response Objects
  • 175 flask.Response
  • 176 flask.Response.headers
  • 177 flask.Response.status
  • 178 flask.Response.status_code
  • 179 flask.Response.data
  • 180 flask.Response.mimetype
  • 181 flask.Response.set_cookie
Sessions
  • 182 flask.session
  • 183 flask.session.new
  • 184 flask.session.modified
  • 185 flask.session.permanent
Session Interface
  • 186 flask.sessions.SessionInterface
  • 187 flask.sessions.SessionInterface.get_cookie_domain
  • 188 flask.sessions.SessionInterface.get_cookie_httponly
  • 189 flask.sessions.SessionInterface.get_cookie_path
  • 190 flask.sessions.SessionInterface.get_cookie_secure
  • 191 flask.sessions.SessionInterface.get_expiration_time
  • 192 flask.sessions.SessionInterface.is_null_session
  • 193 flask.sessions.SessionInterface.make_null_session
  • 194 flask.sessions.SessionInterface.null_session_class
  • 195 flask.sessions.SessionInterface.open_session
  • 196 flask.sessions.SessionInterface.pickle_based
  • 197 flask.sessions.SessionInterface.save_session
  • 198 flask.sessions.SessionInterface.should_set_cookie
  • 199 flask.sessions.SecureCookieSessionInterface
  • 200 flask.sessions.SecureCookieSessionInterface.digest_method
  • 201 flask.sessions.SecureCookieSessionInterface.key_derivation
  • 202 flask.sessions.SecureCookieSessionInterface.salt
  • 203 flask.sessions.SecureCookieSessionInterface.serializer
  • 204 flask.sessions.SecureCookieSessionInterface.session_class
  • 205 flask.sessions.SecureCookieSession
  • 206 flask.sessions.NullSession
  • 207 flask.sessions.SessionMixin
  • 208 flask.sessions.SessionMixin.modified
  • 209 flask.sessions.SessionMixin.new
  • 210 flask.sessions.SessionMixin.permanent
  • 211 flask.sessions.session_json_serializer
Test Client
  • 212 flask.testing.FlaskClient
  • 213 flask.testing.FlaskClient.session_transaction
Application Globals
  • 214 flask.g
Useful Functions and Classes
  • 215 flask.current_app
  • 216 flask.has_request_context
  • 217 flask.copy_current_request_context
  • 218 flask.has_app_context
  • 219 flask.url_for
  • 220 flask.abort
  • 221 flask.redirect
  • 222 flask.make_response
  • 223 flask.after_this_request
  • 224 flask.send_file
  • 225 flask.send_from_directory
  • 226 flask.safe_join
  • 227 flask.escape
  • 228 flask.Markup
  • 229 flask.Markup.escape
  • 230 flask.Markup.striptags
  • 231 flask.Markup.unescape
Message Flashing
  • 232 flask.flash
  • 233 flask.get_flashed_messages
JSON Support
  • 234 flask.json.jsonify
  • 235 flask.json.dumps
  • 236 flask.json.dump
  • 237 flask.json.loads
  • 238 flask.json.load
  • 239 flask.json.JSONEncoder
  • 240 flask.json.JSONEncoder.default
  • 241 flask.json.JSONDecoder
Template Rendering
  • 242 flask.render_template
  • 243 flask.render_template_string
  • 244 flask.get_template_attribute
Configuration
  • 245 flask.Config
  • 246 flask.Config.from_envvar
  • 247 flask.Config.from_json
  • 248 flask.Config.from_mapping
  • 249 flask.Config.from_object
  • 250 flask.Config.from_pyfile
  • 251 flask.Config.get_namespace
Extensions
  • 252 flask.flask.ext
Stream Helpers
  • 253 flask.stream_with_context
Useful Internals
  • 254 flask.ctx.RequestContext
  • 255 flask.ctx.RequestContext.copy
  • 256 flask.ctx.RequestContext.match_request
  • 257 flask.ctx.RequestContext.pop
  • 258 flask.ctx.RequestContext.push
  • 259 flask._request_ctx_stack
  • 260 flask.ctx.AppContext
  • 261 flask.ctx.AppContext.pop
  • 262 flask.ctx.AppContext.push
  • 263 flask._app_ctx_stack
  • 264 flask.blueprints.BlueprintSetupState
  • 265 flask.blueprints.BlueprintSetupState.add_url_rule
  • 266 flask.blueprints.BlueprintSetupState.app
  • 267 flask.blueprints.BlueprintSetupState.blueprint
  • 268 flask.blueprints.BlueprintSetupState.first_registration
  • 269 flask.blueprints.BlueprintSetupState.options
  • 270 flask.blueprints.BlueprintSetupState.subdomain
  • 271 flask.blueprints.BlueprintSetupState.url_defaults
  • 272 flask.blueprints.BlueprintSetupState.url_prefix
Signals
  • 273 flask.signals.signals_available
  • 274 flask.template_rendered
  • 275 flask.request_started
  • 276 flask.request_finished
  • 277 flask.got_request_exception
  • 278 flask.request_tearing_down
  • 279 flask.appcontext_tearing_down
  • 280 flask.appcontext_pushed
  • 281 flask.appcontext_popped
  • 282 flask.message_flashed
  • 283 flask.signals.Namespace
  • 284 flask.signals.Namespace.signal
Class-Based Views
  • 285 flask.views.View
  • 286 flask.views.View.as_view
  • 287 flask.views.View.decorators
  • 288 flask.views.View.dispatch_request
  • 289 flask.views.View.methods
  • 290 flask.views.MethodView
URL Route Registrations
View Function Options
Command Line Interface
  • 291 flask.cli.FlaskGroup
  • 292 flask.cli.AppGroup
  • 293 flask.cli.AppGroup.command
  • 294 flask.cli.AppGroup.group
  • 295 flask.cli.ScriptInfo
  • 296 flask.cli.ScriptInfo.app_import_path
  • 297 flask.cli.ScriptInfo.create_app
  • 298 flask.cli.ScriptInfo.data
  • 299 flask.cli.ScriptInfo.load_app
  • 300 flask.cli.with_appcontext
  • 301 flask.cli.pass_script_info
  • 302 flask.cli.run_command
  • 303 flask.cli.shell_command
1
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?