One of the cheapest, still good working USB webcams is probably the Microsoft LifeCam HD-3000. You can get them used for as low a 3-4 euros.
Attaching it to a printer usually looks messy, so the best way to use it, is to disassemble it and just use the little PCB and USB-cable in a new case.
Check out YouTube videos or the IR-Removal Instructions from Instructables.com to see how you need to disassemble the camera case. It can be a bit tricky to find the screws.
This case mod works great with Core XY printers, but you can always modify my design to your needs. Just use either the Fusion 360 Archive or the STEP file, I have uploaded as well.
Additionally, you need:
1x m4 screw
1x 2020/4040 Extrusion nut
2x m3 screw (6-10mm)
Have fun :)
Release Notes:
v4: Created a left side and right side attachment :-)
v1: First release
The author marked this model as their own original creation.