Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
はてなブログAPI サービス文書URIのレスポンスからコレクションURIを取得
import requests
import bs4
hatena_id = "<hatena id>"
blog_id = "<blog_id>"
password = "<api key>"
def get_collection_uri(hatena_id, blog_id, password):
service_doc_uri = "https://blog.hatena.ne.jp/{hatena_id:}/{blog_id:}/atom".format(hatena_id=hatena_id, blog_id=blog_id)
res_service_doc = requests.get(url=service_doc_uri, auth=(hatena_id, password))
if res_service_doc.ok:
soup_servicedoc_xml = bs4.BeautifulSoup(res_service_doc.content, features="xml")
collection_uri = soup_servicedoc_xml.collection.get("href")
return collection_uri
return False
get_collection_uri(hatena_id, blog_id, password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.