It is not a crime to go through someone's trash as long as the trash can or trash is on the curb which is public property.
If the trash can or trash is on private property then it is a crime to go through the trash.
Such as a dumpster that is on private property whether locked or not locked then that becomes illegal if the owner does not give you permission.
So get the owners permission for private dumpsters because you can be charged with trespassing.
Also do not go through trash cans that are on private property and always wait until the trash cans are out on the curb before going through the trash cans.
Trash that is put out on the curb in most places is considered to be public property and anyone can go through your trash cans legally as long as the trash cans are out on the public curb and not on the persons private property.
If the trash cans or trash is on someone's private property then it's illegal to trespass to get trash or items from peoples trash cans.
But if the trash cans or trash is put out by the curb or on the curb for trash pick up then the trash or anything else that is put out there becomes public property and you're free to take it.
The supreme court ruled in 1988 that you give up your rights to ownership of the items that are put out for trash.
However for recycling bins those are usually off limits so stay out of those to avoid trouble with the law but the trash cans and trash is public property once it's on the curb.
Yes in most places it is illegal to collect cans or any other items from a recycling bin.
The items in the recycling bin are considered to be owned by the city, county or whoever picks up the recycling in the recycling bins.
Your local city should be able to tell you but in most cases and most places going through recycling bins is illegal.
Now as for trash cans that are out on the curb going through those trash cans to get cans or other items that are discarded is not illegal.
That is unless the city has made it illegal to go through peoples trash.
But in most places when you put your trash out by the curb it becomes public property and you gave up your rights to ownership of those trash items