Accurate traffic flow forecasting is very important for urban planning and traffic management. However, this is a huge challenge due to the complex spatial–temporal relationships. Although the existing methods have researched spatial–temporal relationships, they neglect the long periodic aspects of traffic flow data, and thus cannot attain a satisfactory result. In this paper, we propose a novel model Attention-Based Spatial–Temporal Convolution Gated Recurrent Unit (ASTCG) to solve the traffic flow forecasting problem. ASTCG has two core components: the multi-input module and the STA-ConvGru module. Based on the cyclical nature of traffic flow data, the data input to the multi-input module are divided into three parts, near-neighbor data, daily-periodic data, and weekly-periodic data, thus enabling the model to better capture the time dependence. The STA-ConvGru module, formed by CNN, GRU, and attention mechanism, can capture both temporal and spatial dependencies of traffic flow. We evaluate our proposed model using real-world datasets and experiments show that the ASTCG model outperforms the state-of-the-art model.