Though powerful for understanding structure of complex materials, structural modeling of advanced x-ray or neutron scattering data such as pair distribution function (PDF) analysis is difficult and presents a steep learning curve for new users. There are two major challenges. The first is that PDF structure refinement requires a satisfactory plausible starting model to achieve a successful result. The second is that the refinement process is complex and requires significant user inputs to guide it to the best fit whilst avoiding overfitting. This study presents a new approach, called structure-mining, to address both issues. It pulls from structural databases all the known structures meeting the experimenter's search criteria and automatically performs structure refinements on them without human intervention. Tests on various material systems show the effectiveness and robustness of the algorithm in finding the correct atomic crystal structure. It works on crystalline and nanocrystalline materials including complex oxide nanoparticles and nanowires, low-symmetry and locally distorted structures, and complicated doped and magnetic materials.