In Global Navigation Satellite System (GNSS) positioning, observation precisions are frequently impacted by the site-specific unmodeled errors, especially for the code observations that are widely used by smart phones and vehicles in urban environments. The site-specific unmodeled errors mainly refer to the multipath and other space loss caused by the signal propagation (e.g., non-line-of-sight reception). As usual, the observation precisions are estimated by the weighting function in a stochastic model. Only once the realistic weighting function is applied can we obtain the precise positioning results. Unfortunately, the existing weighting schemes do not fully take these site-specific unmodeled effects into account. Specifically, the traditional weighting models indirectly and partly reflect, or even simply ignore, these unmodeled effects. In this paper, we propose a real-time adaptive weighting model to mitigate the site-specific unmodeled errors of code observations. This unmodeled-error-weighted model takes full advantages of satellite elevation angle and carrier-to-noise power density ratio (C/N0). In detail, elevation is taken as a fundamental part of the proposed model, then C/N0 is applied to estimate the precision of site-specific unmodeled errors. The principle of the second part is that the measured C/N0 will deviate from the nominal values when the signal distortions are severe. Specifically, the template functions of C/N0 and its precision, which can estimate the nominal values, are applied to adaptively adjust the precision of site-specific unmodeled errors. The proposed method is tested in single-point positioning (SPP) and code real-time differenced (RTD) positioning by static and kinematic datasets. Results indicate that the adaptive model is superior to the equal-weight, elevation and C/N0 models. Compared with these traditional approaches, the accuracy of SPP and RTD solutions are improved by 35.1% and 17.6% on average in the dense high-rise building group, as well as 11.4% and 11.9% on average in the urban-forested area. This demonstrates the benefit to code-based positioning brought by a real-time adaptive weighting model as it can mitigate the impacts of site-specific unmodeled errors and improve the positioning accuracy.