2

在我的应用程序中,当我使用 urlfetch.fetch 函数获取指定的 url 时,我发现我得到的内容对于一些特殊的 html 代码是空的。

例如 真实html源码中的url: http ://www.club.cn.sodexo.com/node/5071,代码包括:

<div class="content">
<div style="width: 219px; height: 262px;" id="gmap-auto3map-gmap0" class="gmap-control gmap-gmap gmap gmap-map gmap-auto3map-gmap">Javascript is required to view this map.</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery.extend(true, Drupal, { settings: { "gmap": { "auto3map":{ "width": "219px", "height": "262px", "zoom": 16, "maxzoom": "17","controltype": "Large", "align": "None", "maptype": "Map", "mtc":"none", "baselayers": { "Map": 1, "Satellite": 1, "Hybrid": 1 },"styles": { "line_default": [ "0000ff", "5", "45", "", "" ],"poly_default": [ "000000", "3", "25", "ff0000", "45" ] },"line_colors": [ "#00cc00", "#ff0000", "#0000ff" ], "behavior":{ "autozoom": true }, "markermode": "0", "id": "auto3map", "latitude":"31.239132", "longitude": "121.483506", "markers": [ { "latitude":"31.239132", "longitude": "121.483506", "markername": "small red","offset": 0, "opts": { "title": "克莉丝汀食品(宁波路店)" }, "text": "\x3cdiv class=\"gmap-popup\"\x3e\x3c/div\x3e" } ] } } } });
/* ]]> */
</script>
</div> 

但根据我通过 url fetch 得到的结果:结果将是:

<div class="content">
<div style="width: 219px; height: 262px;" id="gmap-auto3map-gmap0" class="gmap-control gmap-gmap gmap gmap-map gmap-auto3map-gmap">Javascript is required view this map.</div>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>

/* <![CDATA[ */和之间的所有javascript代码/* ]]> */都被遗漏了,这是如此连线。有谁知道这个问题?有可能解决这个问题吗?

4

1 回答 1

0

也许服务器会根据用户代理插入不同的 javascript(即 Firefox 与 Internet Explorer 的不同代码),而对于urlfetch's user-agent 服务器会感到困惑并且根本不插入任何 javascript。

于 2011-03-31T03:49:34.050 回答