Good question! This didn't used to be possible but should be today with random access. When I need this it's generally because I want to add something to those items, and if you are certain of the spelling you can use quick_statements to add the statement and then collect the q numbers that way. The problem with this approach is that you can easily add double statements and you theoretically only want to augment the existing statements per item, not duplicate them. Of course if all items share some common statement you may be able to query that statement and filter the results. Another way I do this is with listeria. For example if I want the artists in a collection, I set up a listeria query for all artworks in the collection and include the creator field. Afterwards I collect the result and filter for the artists' names or q numbers. Obvious problem here is that most collections on Wikidata only include the most popular artworks in the collection, because these are coming from the various wikipedia projects. There are still lots and lots of artworks on Commons without wikidata items.Hope it helps.