Legal? Yes. Ethical? Technically. A good idea? Not really.
Employers will forgive short term stuff if you're a contractor or freelancer; they'll even forgive a little bit of "job-hopping" from the past 5 or so years (since the economy tanked, and in a lot of cases, the only way up is out), but people talk. You won't be able to pass your job hopping off as "contracting" if it really wasn't (if it was, then that can work to your advantage, since it's easily and viably dismissed as "the contract ended"). Someone is bound to know someone at one of your previous jobs, and you can bet they'll talk to them, with or without your consent. When they do, they'll find out that not only are you a job hopper, but also a liar. So, at best, you're a job hopper, and at worst, a dishonest job-hopper. Pretty soon, people will just stop contacting you.
What it sounds like you need is a change in approach in how you look for a job and what you want from a job. If you make your needs and desires concrete, I'm willing to bet that you'll be able to find a good fit far sooner than several months in (even as soon as the in-person interview).
Start out with the easy stuff - pay, benefits, etc. Is the prospect willing to pay you what you're worth? Do they have the benefits you want? If so, that's points for them. Do they have benefits that go over and above, such as nap pods, catered meals, a gym, or beer fridge? Bonus points, especially if you're interested in what they have to offer.
Do they allow telecommute? Even if you don't use it yourself, their attitude toward working remotely can say a lot about a company. In my experience, management that truly allows working remotely on some level will likely care more about your work than about politics (the more liberal the remote work policy, often the more results-oriented they are). This is a very good thing and can save you a lot of headache in the long run.
When you talk to the people at the company, what are their personalities like? Are these people you think you'd like to be around for 8-12 hours a day, five days a week? In the interview, do they stick with purely work-related stuff, or do they ask about non-work stuff beyond the almost-obligatory "what are your hobbies?" boilerplate question? Did you get into a discussion with one of the employees about the latest GitHub Drinkup, or the last boss in Final Fantasy? If you're there long enough to observe behavior between employees, what's it like?
What is the office like? Cube farm, offices, a giant round table? Quiet? Loud? Is the setup something that you'd be willing to work in all day? Don't forget to take note of the acoustics. It might be quiet now, but does it look like it's always quiet? If not, can you hide in an office when necessary? Is there a good amount of natural light? Are people's desks decorated (even with practical stuff), or sterile?
What was their screening process? Not everyone has to get 100% on the Joel test, but does their process for hiring someone show that they care about the quality of the people they hire? When do the engineers get involved? Is there any kind of committee interview or decision process that involves the people you'll be working with and/or for (and do you know how much say they have in it)?
Don't be afraid to ask questions The interview process is as much about you finding the right employer as them finding the right employee. Ask questions about the company. Are there impromptu group outings (or other thing arranged by the employees, and not just the cheesy stuff by management)? Are they understanding of the needs of the type of people that the high tech jobs attract? Do they plan in going a different direction, or making major changes to their structure in the near future? I've had cases where a company was a fit at first, but then changes happened and it was no longer a fit after several months, or even years. It happens. Sometimes it's foreseeable, sometimes it isn't. Ask. If they're planning major changes and they can tell you about them, you can either try it and see if it works out (sometimes, the change stays in line with what made the company a fit, sometimes it doesn't; if it doesn't, you can explain in your next interview that the company moved in a different direction from where you wanted to go), or you can turn down the offer.
Write down and prioritize your list of needs and wants. I have recruiters calling and emailing me on such a regular basis about job leads (we have far too many agencies in my area) that I ended up coming up with a response that details what it is that I'm looking for in my dream company (for some of the more progressive stuff, I include an example of someone pulling it off successfully, such as GitHub's remote working policy and results-oriented nature) and that I'm going to be picky about what I consider. What it did was force me to write down exactly what it was I wanted in a company and make some kind of prioritization for it. I found this to be an extraordinarily good thing, because then the recruiters know what I'll turn away and what I'll look at. I've also found that, because I have this pretty solidified, I can weed out a lot of "cool-but-not-a-fit" employers at the job posting, before I even get to an interview, because I know what I want and need to thrive at any given job.
Set high standards You know what you want. If you've been through a few employers already, you probably also know what you don't want, so don't accept anything that has too much of what you don't want or not enough of what you do want. You may not get a 100% perfect fit, but it's a balancing act. For example, my current job has us in cubicles (which to me, isn't ideal), but our office has a ton of natural light (all of the exterior walls are glass), there's not much in the way of office politics, and we're free to listen to music with headphones. For me, this more than balances out the cube farm, which was more toward the "rather not have, but not necessarily dealbreaker" end of my list. However, had the office been loud, I likely would have turned down the position outright.
If you have a company that you absolutely drool over to work at (such as an animator wanting to work for Pixar, or a developer working for Google, or whatever), see what it is, besides the prestige, that makes you want to work for them. Then, look for that in your prospective employers. If they don't have enough of those qualities, then turn them down.
Sleep on it When you get a job offer, you don't have to accept it instantaneously. If you're unsure about whether you want to take it, ask if you can respond in a day or two. Take that time to consider whether you really want that job.
There's a rule of thumb in (women's) clothes shopping - "if you don't absolutely love it in the store, you'll hate it when you get home." I think the same principle applies to most jobs, as well. If you have doubts for whatever reason about a company, then don't take the job. Before you get hired, no one's out anything except a little time and you're not as likely to burn any bridges. Could you have potentially missed out on something really awesome? There's a slight chance, but to be honest, it's not likely that the company you just turned down would be the next Google or Facebook, and even if they are, there are tons of other opportunities to get in on something else that's really cool.