0

我想提取本网站上列出的下拉控件中可用的名称/值对:http: //www.dotmed.com/listings/postlisting.html? type=equipment&mode=sale

初始列表是静态的,因此很容易做到。但是,其余部分似乎是动态填充的。提取这些名称/值对的最简单方法是什么?

4

1 回答 1

1

动态加载的框由 ajax 查询调用。
这是单击一个时发送的标头请求。

http://www.dotmed.com/ajax/components/ajax

POST /ajax/components/ajax HTTP/1.1
Host: www.dotmed.com
User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:19.0) Gecko/20100101 Firefox/19.0
Accept: text/javascript, text/html, application/xml, text/xml, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.6.0.3
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://www.dotmed.com/listings/postlisting.html?type=equipment&mode=sale
Content-Length: 96
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
_comp=%2Fajax%2Fcomponents%2Flistings%2Fshow_categories&_t=equipment&form=select_form&_h=28&_c=2
HTTP/1.1 200 OK
Date: Fri, 29 Mar 2013 19:59:47 GMT
Server: Apache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

您感兴趣的线路是

_comp=%2Fajax%2Fcomponents%2Flistings%2Fshow_categories&_t=equipment&form=select_form&_h=28&_c=2

_h= 包含您选择的选项值。
_c= 包含,我想,需要填充的框

So, if you want to get the list of items for the second box for the selection "Cosmetic", you'd grab the id (30) and change _h.

If you want the data for the third box for cosmetic->chiller, You would change _h to 2738 and _c to 3

Basically, you just need to see what you're sending to the server when you're clicking it and then send it a bunch of requests for everything else.

于 2013-03-29T20:08:20.377 回答