The total price you pay/receive always includes accrued interest so if you buy a bond just before the coupon payment then you will pay the seller the proportional amount of that coupon, which in case of a day or two before it means practically the whole coupon.
Sorry, no free lunch here.