Provided is an X-ray source. The X-ray source comprises a control circuit, an ordinary light source, an optical module, a photocathode, an electron beam focusing structure, an anode target, an X-ray exit window, an ordinary light incidence window and a vacuum container, wherein the control circuit is used for controlling a working state of the ordinary light source, the ordinary light source is used for emitting light rays with a specific wave length range, the optical module is used for focusing the light rays emitted by the ordinary light source, the photocathode is used for generating electrons through optical excitation, the electron beam focusing structure is used for focusing electro beams generated by the photocathode, the anode target receives bombardment of accelerated electrons, and generates X-rays through bremsstrahlung, the X-ray exit window and the ordinary light incidence window are arranged on the vacuum container, and the vacuum container is used for packaging the photocathode, the electron beam focusing structure and the anode target. The X-ray source has the advantages of being high in time resolution, programmable, capable of achieving impulse type emission, changeable in size and shape of an emission area, capable of enabling a high voltage to be easily connected, low in difficulty of connection, capable of enabling heat dissipation of the anode target to be easy, and relatively simple in structure. The invention further provides an X-ray generating method.