Almost certainly, however it depends how much CPU power is available to the shared host (probably about as much as your desktop to be honest), in which case you'll see yourself booted off in short order. Shared hosts tend to be stack-em-high affairs, where you can get 100s of sites hosted.
You could go for a virtual host, where they will give you freedom to do whatever you like, but you'll probably find there that the amount of CPU power you're restricted to is limited, possibly too limited for you. Virtual hosts tend to split the host between several virtual guests, sometimes as little as 4, but more often (and especially for the cheaper plans) all the way up to 64.
Your third option then is to go for a fully dedicated server, you get a whole server all you yourself and can do what you like with it. These tend to be expensive if you want lots of server hardware (because it uses a lot of very expensive electricity), or lots of bandwidth.
Obviously those 3 options increase in cost, in the webhosting arena, you do get what you pay for.
You might like to find a webhosting forum and ask around on there - be sure to specify the CPU requirements, and how long its likely to take. You may get some hoster that'll be more than happy for you to run your script in the 'out of hours' if you agree a time with them (that doesn't interfere with backups, or if they have lower resource time, as websites tend to be accessed around the world in every timezone)