【问题标题】:How do I track the route to my destination page from various 301s?如何跟踪从各种 301 到目标页面的路线?
【发布时间】:2011-05-18 05:14:28
【问题描述】:

对于可能知道的人来说很简单的问题,对我来说是世界上最困难的事情:

有这个网址:http://hstgb.tradedoubler.com/file/118779/banners/searchboxes/holidays_search_8Sep09.html?url=http://clkgb.tradedoubler.com/click?p=118779&a=1868402&g=18436588

这是一个附属网址(我不是想让你买任何东西;))

现在,当我单击搜索时,它会将我带到一个中间页面,然后将参数发送到 lastminute 以打开目标页面。

第二页过得很快,我无法查看它或无论如何阅读它的源代码。如何跟踪发送的页面和参数?

【问题讨论】:

    标签: redirect http-status-code-301


    【解决方案1】:

    您可以使用诸如Wireshark 之类的数据包嗅探器或监控网络流量的浏览器插件来捕获发送的每个请求和接收的每个页面。

    【讨论】:

      【解决方案2】:

      好吧,我写了一个小python来找出答案。

      import urllib
      
      def make_request(url, method='GET'):
          protocol, hostpath = urllib.splittype(url)
          if hostpath[:2] != '//':
              hostpath = '//' + hostpath
          host, path = urllib.splithost(hostpath)
          if len(path.strip()) == 0 or path[0] != '/':
              path = '/' + path
          query = "%s %s HTTP/1.1\r\nHost: %s\r\n\r\n"%(method, path, host)
          if protocol != 'http' and protocol is not None:
              raise ValueError, 'Invalid protocol specified.  http only'
      
          addresses = socket.getaddrinfo(host, 80)
          return (addresses, query)
      
      
      def do_request(addresses, query):
          sock_type = addresses[0][:3]
          addr = addresses[0][4]
          connection = socket.socket(*sock_type)
          connection.connect(addr)
          connection.sendall(query)
          return connection
      
      def urlpeek(url):
          return do_request(*make_request(url))
      

      当我查看您提供的地址时,看起来服务器实际上正在返回一个 200 OK 响应,主要由 javascript 组成...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-29
        • 1970-01-01
        相关资源
        最近更新 更多