[PYTHON] I touched the Qiita API

I wanted to link Qiita's post with twitter, so I touched on the Qiita API for a moment. This time, I used python wrapper because I want to do it quickly.

I tried to do the following two points this time

As a preparation for this, I first tried to get my own posts at regular intervals.

How to use the wrapper is basically written on the above link page, and if you want to know more, refer to the code dropped by pip. Although it is not necessary for this operation, the process from Oauth authentication to post list acquisition is as follows.

client = Client(url_name = self.user_name, password = self.user_pass)
token = client.token #For post etc., use the token obtained here
users = Users()
user_items = users.user_items(url_name=self.user_name, params={'page':1, 'per_page':100})

See Official document for the format of the returned value. The value you want here is'created_at'for the posting date and time, so you can extract it like ʻuser_items [0] ['created_at']. The format that can be obtained is as 2014-10-11 23:34:14 + 0900`, and it is necessary to convert this to the datetime format for date / time comparison. At this time, the time zone attached at the end is an obstacle, so if you convert it while scraping it, it will be as follows.

In [42]: time_str = '2014-10-11 23:34:14 +0900'

In [43]: time = datetime.strptime(time_str[:-6], '%Y-%m-%d %H:%M:%S')

In [44]: (datetime.now() - time).days
Out[44]: 7

I feel like I should extract the data like this. The current situation is really an introduction, but I want to get it into shape as soon as possible.

Postscript

The difference between days is not the date, but is rounded down by 24 hours, so if it is within one day, days <1 seems to be good.

Recommended Posts

I touched the Qiita API
I tried hitting the Qiita API from go
I tried the Naruro novel API
I tried using the checkio API
I touched HaikuFinder
I touched Flask
I stumbled on the Hatena Keyword API
I tried to touch the COTOHA API
I touched the data preparation tool Paxata
I tried using the BigQuery Storage API
I tried to get the authentication code of Qiita API with Python.
I checked the library for using the Gracenote API
Created a Python wrapper for the Qiita API
I tried using the Google Cloud Vision API
I tried to touch the API of ebay
I touched some of the new features of Python 3.8 ①
Qiita Job I tried to analyze the job offer
I checked the calendar deleted in Qiita Advent Calendar 2016
I made a Python Qiita API wrapper "qiipy"
I touched TensorFlow's Tensorboard
I counted the grains
I touched AWS Chalice
[Trainer's Recipe] I touched the flame of the Python framework.
I tried using the API of the salmon data project
A memo that I touched the Datastore with python
I moved the automatic summarization API "summpy" with python3.
I tried hitting the API with echonest's python client
I touched Wagtail (1) and let's override the save method.
[First COTOHA API] I tried to summarize the old story
I examined the device tree
I touched the latest automatic test tool "Playwright for Python"
I wrote a Python script that exports all my posts using the Qiita API v2
Try using the Twitter API
I tweeted from the terminal!
Try using the Twitter API
The Linux Watchdog driver API
I tried the changefinder library!
I tried saving the DRF API request history with django-request
I tried touching the multi-vendor router control API library NAPALM
Try using the PeeringDB 2.0 API
I touched Wagtail (2). Introducing django-extensions.
[Python] I tried collecting data using the API of wikipedia
I tried the Google Cloud Vision API for the first time
Call the API with python3.
I touched Tensorflow and keras
I tried to get various information from the codeforces API
I made an original program guide using the NHK program guide API.
I downloaded the python source
Qiita API Oauth with Django
[For beginners] I tried using the Tensorflow Object Detection API
I read the SHAP paper
I tried scraping the ranking of Qiita Advent Calendar with Python
Get the number of PVs of Qiita articles you posted with API
I created a Python library to call the LINE WORKS API
I tried using the COTOHA API (there is code on GitHub)
I made a Twitter Bot with Go x Qiita API x Lambda
Continuation ・ I tried touching the multi-vendor router control API library NAPALM
I tried the TensorFlow tutorial 1st
I touched PyAutoIt for a moment
I tried to create Quip API
Get the number of views of Qiita