Scripting HTTP more effeciently

2019-03-11 14:57发布

Often times I want to automate http queries. I currently use Java(and commons http client), but would probably prefer a scripting based approach. Something really quick and simple. Where I can set a header, go to a page and not worry about setting up the entire OO lifecycle, setting each header, calling up an html parser... I am looking for a solution in ANY language, preferable scripting

12条回答
神经病院院长
2楼-- · 2019-03-11 15:30

My turn : wget or perl with lwp. You'll find example on the linked page.

查看更多
我命由我不由天
3楼-- · 2019-03-11 15:33

Have a look at Selenium. It generates code for C#, Java, Perl, PHP, Python, and Ruby if you need to customize the script.

查看更多
三岁会撩人
4楼-- · 2019-03-11 15:36

Some ruby libraries:

  • httparty: really interesting, the philosophy is interesting.
  • mechanize: classic good-quality web automatization library.
  • scrubYt: puzzling at first glance but fun to use.
查看更多
神经病院院长
5楼-- · 2019-03-11 15:41

Watir sounds close to what you want although it (like Selenium linked to in another answer) actually opens up a browser to do stuff. You can see some examples here. Another browser based record + playback approach system is sahi.

If your application is uses WSGI, then paste is a nice option.

Mechanize linked to in another answer is a "browser in a library" and there are clones in perl, Ruby and Python. The Perl one is the original one and this seems to be the way to go if you don't want a browser. The problem with this approach is that all the front end code (which might rely on JavaScript), won't be exercised.

查看更多
姐就是有狂的资本
6楼-- · 2019-03-11 15:41

What about using PHP+Curl, or just bash?

查看更多
Viruses.
7楼-- · 2019-03-11 15:42

Mechanize for Python seems easy to use: http://wwwsearch.sourceforge.net/mechanize/

查看更多
登录 后发表回答