I would say sift through a component distributor's website, such as Farnell
Then go about sorting one option at a time.
Connectors > Board-to-board/Wire-to-board/stacking (stacking would be my first choice) > then start selecting various parameters, such as 40 pins, 2 rows, 1.27mm pitch (I'd measure this if possible, but it's fairly standard and looks about right).
Hopefully there won't be too many components found, around 100 or so (4 pages).
If you still can't find it, then try a different branch higher up the tree, such as board-to-board connector, or even ffc/fpc based on your second picture.
Sorry I don't know outright, and good luck!