开发者

How do I track the route to my destination page from various 301s?

Simple question for someone who might know, the most difficult thing in the world for me:

There's this url: http://hstgb.tradedoubler.com/file/118779/banners/searchboxes/holidays_search_8Sep09.html?url=http://clkgb.tradedoubler.com/click?p=118779&a=1868402&g=18开发者_Go百科436588

It's an affiliate url (I'm not trying to get you to buy anything ;) )

Now when I click search, it takes me to an intermediary page, which then sends parameters to lastminute to open the destination page.

The second page goes so quickly that I cannot view it or anyhow read it's source code. How do I track the page and parameters sent?


You could use a packet sniffer such as Wireshark or a browser add-on that monitors network traffic, to capture every request that gets send and every page that gets received.


Well, I wrote a little python to find out.

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))

When I perform a peek on the address you give, it looks like the server is actually returning a 200 OK response, which consists mainly of javascript...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜