开发者

How to access web form programmatically?

http://coun开发者_运维知识库trysize.com/ has two pulldown menus where country names can be selected.

I am trying to make a bash program to automatically take screenshot of the result for any given two countries. I.e. I don't want to manually select two countries in browser, and then take screenshot. The goal is to get the complete set of country area comparison results.

How do I programmatically do this?


If the form on the page uses method=get, and the query parameters are passed in the URL there would be a URL for every pair. However, if that were the case, you would see the resulting URL in your browser.

If the form uses method=post, the choices are sent as part of the form submission and included in the body of the web request. There are command line tools that you can call from a bash script that will send a form submission of this type. The tools "curl" and "wget" can both do this.

However, this page looks like something else is going on. The page requires javascript, and the code to do the actual work is probably in javascript. Normally, that would mean you could not easily script it with a command line script.

However... There are a few links on the page for some comparisons:

http://countrysize.com/?cou1=pk&cou2=sp     = Kenya : France
http://countrysize.com/?cou1=xxsct&cou2=be  = Scotland : Belgium
http://countrysize.com/?cou1=gl&cou2=br     = Greenland : Brazil
http://countrysize.com/?cou1=iz&cou2=is     = Iraq : Israel
http://countrysize.com/?cou1=ei&cou2=xxsct  = Ireland: Scotland

If you can figure out which codes go with each country, you could use the URLs.


You don't have to use the checkboxes; just go by url and replace the parameters: http://countrysize.com/?cou1=pk&cou2=es

in this example it's pk = pakistan and es = el salvador

Google can find the complete list of all valid country codes for you. Now you just have to take the screenshots.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜